harshjain30
BAN USER
Comments (5)
Reputation 10
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
1. Traverse the array and store a count array.
2. Traverse the array again and for each element x, add the values in count_array[x:9]. This is the value we need
3. count_array[x]--
Complexity: O(n) + O(n)*[0-9] = O(n)
Comment hidden because of low score. Click to expand.
0
of 0 vote
Yossi, what would you do for "--"? If you wanna replace it with "---", consider this: how would you distinguish ["goog-", "le"] from ["goog--le"]?
- harshjain30 January 31, 2016Comment hidden because of low score. Click to expand.
1
of 1 vote
58 mins and 50 seconds (5/6th the distance)
- harshjain30 January 30, 2016Comment hidden because of low score. Click to expand.
0
of 0 vote
0.0001 is added to ensure sqrt(n) is included in the iteration. The for..range in Python is exclusive at the closing bound.
This is the most efficient solution btw.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
This is wrong. Swapping will not work. example: 0,5,3,1,2 becomes 0,5,2,3,1 and then 1 is printed as missing.
- harshjain30 February 02, 2016