Conversation
IreneNakiyingi
left a comment
There was a problem hiding this comment.
Function search (line 28) is missing execution of a condition; otherwise return -1;
| nums.sort; | ||
| let i = nums.indexOf(target); | ||
| return i; | ||
| }; |
There was a problem hiding this comment.
Irene stated a condition that you missed here
There was a problem hiding this comment.
Also the question requires that You must write an algorithm with O(log n) runtime complexity. This solution does not satisfy that requirement even though it works. You might want to check that out
There was a problem hiding this comment.
Also the question requires that
You must write an algorithm with O(log n) runtime complexity. This solution does not satisfy that requirement even though it works. You might want to check that out
Okay
Done, Thank you
There was a problem hiding this comment.
This solution is O(n) time complexity. Look up Binary search and view some examples with various solutions as Mary suggested, will help a lot in understanding.
No description provided.