leetcodeSolution to some Leetcode problems written in C++ | 
          
| git clone git://git.dimitrijedobrota.com/leetcode.git | 
| Log | Files | Refs | README | LICENSE | 
0167.cpp (402B)
    0 class Solution {
              1   public:
              2     vector<int> twoSum(vector<int> &numbers, int target) {
              3         int i = 0, j = numbers.size() - 1;
              4         while (i < j) {
              5             int sum = numbers[i] + numbers[j];
              6             if (sum == target)
              7                 return {i + 1, j + 1};
              8             else if (sum < target)
              9                 i++;
             10             else
             11                 j--;
             12         }
             13         return {};
             14     }
             15 };