Skip to content

Commit 302145c

Browse files
Added solution for Two Sum Problem in LeetCode #27
1 parent 468727c commit 302145c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

leetcode/cpp/Array/1.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public:
3+
vector<int> twoSum(vector<int>& nums, int target)
4+
{
5+
vector<int> a;
6+
for (int i=0; i<nums.size(); i++)
7+
{
8+
for(int j=i+1; j<nums.size(); j++)
9+
{
10+
if(nums[i] + nums[j]==target)
11+
{
12+
a= {i,j};
13+
break;
14+
}
15+
}
16+
}
17+
return a;
18+
}
19+
};

0 commit comments

Comments
 (0)