Given an array of size n and value from 1-n. Find the number of times each value occured in array inplace. and O(n).
Easy one: Lets say array is a[].
size is N
while ( i < n)
a[a[i]%N] += N
Easy one: Lets say array is a[].
size is N
while ( i < n)
a[a[i]%N] += N
Comments
Post a Comment