the most simple


  • 0
    D

    class Solution {
    public:
    vector<int> twoSum(vector<int>& nums, int target) {
    vector<int> arr;
    for (int i = 0; i < nums.size(); i++) {
    for (int j = i + 1; j < nums.size(); j++) {
    if ((nums[i] + nums[j]) == target) {
    arr.push_back(i);
    arr.push_back(j);
    return arr;
    }
    }
    }

    }
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.