Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it.
There are multiple ways to solve this problem. Here are a couple of them:
1. Sort the array and compare 1-1 elements.
2. Maintain a bit set with size N with the array[i] as the key, if a bit is already set then a duplicate
is found.
1. Sort the array and compare 1-1 elements.
2. Maintain a bit set with size N with the array[i] as the key, if a bit is already set then a duplicate
is found.
Comments
Post a Comment
https://gengwg.blogspot.com/