O(N log N), O(N) if already sorted.
Rather than sorting the inputs, I would sort the indexes. That way, you wouldn't need an extra hash an array, just an array.
In reply to Re^2: LeetCode Problem #1 - Two Sum - Improve and/or discuss.
by ikegami
in thread LeetCode Problem #1 - Two Sum - Improve and/or discuss.
by kcott
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |