167.两数之和 II - 输入有序数组 - 双指针+哈希数组

原题链接:https://leetcode.cn/problems/two-sum-ii-input-array-is-sorted/
题解
方法1:双指针
左指针和右指针从数组两边开始遍历
当和小于target时左指针++,反之右指针–
1 | class Solution { |
方法2:哈希数组
1 | class Solution { |
Comments
原题链接:https://leetcode.cn/problems/two-sum-ii-input-array-is-sorted/
方法1:双指针
左指针和右指针从数组两边开始遍历
当和小于target时左指针++,反之右指针–
1 | class Solution { |
方法2:哈希数组
1 | class Solution { |