Givens
- Your returned answers (both index1 and index2) are not zero-based.
- You may assume that each input would have exactly one solution and you may not use the same element twice.
Analysis
- Array is sorted, so we can exploit the fact and stop when we reach a certain threshold.
- When we see sorted array, binary searches can be a viable option.
1 | class Solution { |