@Manmeet; So {1,2,2,5,5,6} is valid? Dave
On Dec 9, 9:52 am, Manmeet Singh <mans.aus...@gmail.com> wrote: > u can also compute sum in 1 iteration along with min, max. > now max * (max+1) / 2 - min * (min - 1) / 2 = sum > if it is true then answer is yes > > > > On Thu, Dec 9, 2010 at 6:00 PM, Terence <technic....@gmail.com> wrote: > > A[1..N] is Valid <=> max{A[i]} - min{A[i]} == N-1 > > > On 2010-12-9 20:16, Prims wrote: > > >> Given array A with n elements, give an algorithm for finding whether > >> it’s a valid array or 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 algoge...@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.