Marcus.Danielsson.86
BAN USER
Comments (3)
Reputation -5
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
If you know the expected difference between the values you could just loop through and when you spot a difference between index i and i +1 you could just abort when you find the missing value. On average you need to loop through
n/2 but worst case is n, so this will be O(n)
Comment hidden because of low score. Click to expand.
0
of 0 vote
The answers varies on conditions,
Insert in a sorted LinkedList is O(n).
Insert in a unsorted LinkedList is O(1).
HashMap is a bit more complex, usually O(1) but worst case O(n).
This is depending on your hash function and collisions etc.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Coincidence? I think not
- Marcus.Danielsson.86 April 11, 2017hackerrank.com/contests/w31/challenges/accurate-sorting