Problem
167. Two Sum II - Input array is sorted
Java
Brute-force
1 | class Solution { |
Submission Detail
- 17 / 17 test cases passed.
- Runtime: 191 ms, faster than 7.92% of Java online submissions for Two Sum II - Input array is sorted.
- Memory Usage: 39.6 MB, less than 16.46% of Java online submissions for Two Sum II - Input array is sorted.
binary search
1 | class Solution { |
Submission Detail
- 17 / 17 test cases passed.
- Runtime: 2 ms, faster than 21.89% of Java online submissions for Two Sum II - Input array is sorted.
- Memory Usage: 39.2 MB, less than 45.66% of Java online submissions for Two Sum II - Input array is sorted.
Two Pointer
Algorithm Two Pointer Technique:
The two pointer technique is a useful tool to utilize when searching for pairs in a sorted array.
1 | class Solution { |
Submission Detail
- 17 / 17 test cases passed.
- Runtime: 0 ms, faster than 100.00% of Java online submissions for Two Sum II - Input array is sorted.
- Memory Usage: 39.4 MB, less than 33.74% of Java online submissions for Two Sum II - Input array is sorted.