O(2n) algo
1st traversal
calculate min
calculate sx=1^2^.....^N
where N= no of elements
2nd traversal
fx=(A[1]-min+1)^(A[2]-min+1)...........^(A[N]-min+1)
Now if sx=fx
Array is valid otherwise not
Array is called Valid if all the numbers appearing in A [1...N] are
> consecutive numbers.
>
> Example: A={5,3,4} is a valid array
> A={3,7,5,4,6} is a valid array
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
--
Regards
Aditya Kumar
B-tech 3rd year
Computer Science & Engg.
MNNIT, Allahabad.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.