Montijack
BAN USER
Comments (4)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
Step-1: Iterate whole array 'Arr' and Find 'MAX', 'MIN' and 'LENGTH'.
Step-2: if( MAX - MIN + 1 != LENGTH) return false;
Step-3: Generate a HashMap. Check if we have a collision with newly inserted value if so return false or else return that value from Arr to HashMap.
Step-4: If Step-3 iterates through all values of array 'Arr' without any collision then return true.
Complexity: Time O(n), Space O(n)
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
- Montijack November 14, 2018