leetcode 兩數之和II-輸入有序數組 C++

由於給定數組爲升序排列,所以可以利用該條件進行判斷, 爲數組設置雙指針,分別從前往後和從後往前變化,代碼如下: class Solution { public: vector<int> twoSum(vector<int>& numbers, int target) { auto len=numbers.size(); vector<int> index;
相關文章
相關標籤/搜索