class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> I; int y; for (int x=0; x<nums.size(); x++) { y=0; for (int z=x+1; z<nums.size(); z++) { y=nums[x]+nums[z]; if(y==target) { I.push_back(x); I.push_back(z); break; } } } return I; } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter