水题。
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> result;
int idx_i, idx_j;
bool solved = false;
for (idx_i = 0; idx_i < nums.size() - 1; idx_i++) {
if (solved) {
break;
}
for (idx_j = idx_i+1; idx_j < nums.size(); idx_j++) {
if (solved) {
break;
}
if (nums[idx_i] + nums[idx_j] == target) {
result.push_back(idx_i);
result.push_back(idx_j);
solved = true;
break;
}
}
}
return result;
}
};