Issue 5: LeetCode Two Sum
Task Description:
Is this issue we will solve the first leetcode problem called "Two Sum", for the problem description, go to Problem Link.
Target File:
For leetcode problems, we have setup the structure inside the dsa folder. For this particular issue, go to:
dsa/leetcode/easy/_examples/1.cpp
Copy this 1.cpp file and make a folder by your name (If it doesn't exist) at:
dsa/leetcode/easy/yourName
Paste your 1.cpp in your created folder and then work on this file.
File Structure:
Your file will look like this:
#include<iostream>
#include<vector>
using namespace std;
// Go To Leetcode, Go to problems tab, then search "Two Sum"
// Solution Class
class Solution {
public:
vector<int> twoSum(vector<int>& nums,int target) {
// Your Code Here
}
};
// Main Function
// (Dont Change Anything in main)
// (You can change the testCase values and target value for testing)
int main() {
Solution s;
vector<int> testCase={2,7,11,15};
int target=9;
vector<int> answer=s.twoSum(testCase,target);
for(int i=0;i<answer.size();i++)
cout<<answer[i]<<" ";
return 0;
}
Guidelines:
You are only supposed to write your code in the "twoSum function" inside the "Solution class" in 1.cpp file. Dont change anything in the "main function" other than the values of "vector testCase" and "int target". You can change these values to test your function on different values to make sure it is working correctly before submitting on leetcode. When you are satisfied that your function is now working. Copy only the "Solution class" and paste it in the code section on the leetcode page of this problem. Then submit it ... If your code gets accepted in submission ... Congratulations. If not, then leetcode will also give you the testcase that failed your code. Then work on passing that test case as well ... When your code gets accepted, submit your PR to be merged in main.
Important Note:
- Do Not Submit Ai Generated Codes!
- Make sure your code is submitted and accepted on Leetcode before you make your PR.
- Do not rename the 1.cpp file to anything else.
- Before submitting your PR, make sure you delete the executable file and leave only cpp file.
- Do not read other's cpp files in their PR, just make sure that they aren't pushing any executables and approve the PR.
- If applicable, embed the link to the solution of your 1.cpp in the PR
- Explain the approach you adopted to solve the problem in your PR's description
Issue 5: LeetCode Two Sum
Task Description:
Is this issue we will solve the first leetcode problem called "Two Sum", for the problem description, go to Problem Link.
Target File:
For leetcode problems, we have setup the structure inside the dsa folder. For this particular issue, go to:
dsa/leetcode/easy/_examples/1.cppCopy this 1.cpp file and make a folder by your name (If it doesn't exist) at:
dsa/leetcode/easy/yourNamePaste your 1.cpp in your created folder and then work on this file.
File Structure:
Your file will look like this:
Guidelines:
You are only supposed to write your code in the "twoSum function" inside the "Solution class" in 1.cpp file. Dont change anything in the "main function" other than the values of "vector testCase" and "int target". You can change these values to test your function on different values to make sure it is working correctly before submitting on leetcode. When you are satisfied that your function is now working. Copy only the "Solution class" and paste it in the code section on the leetcode page of this problem. Then submit it ... If your code gets accepted in submission ... Congratulations. If not, then leetcode will also give you the testcase that failed your code. Then work on passing that test case as well ... When your code gets accepted, submit your PR to be merged in main.
Important Note: