Skip to content

Add LeetCode-1 (different approach) and LeetCode-167 in C++ #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 17, 2021

Conversation

r8025n
Copy link
Contributor

@r8025n r8025n commented Aug 6, 2021

resolves #42

Copy link
Owner

@Tahanima Tahanima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @r8025n
Please resolve all the requested changes. Also, change the folder name from 167_TwoSum II to 167_TwoSumII

class Solution {
public:
vector<int> twoSum(vector<int>& numbers, int target) {
int index1 = 0, index2 = numbers.size()-1, sum;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this code to

int index1 = 0, index2 = numbers.size() - 1, sum;

public:
vector<int> twoSum(vector<int>& numbers, int target) {
int index1 = 0, index2 = numbers.size()-1, sum;
vector<int> returnVector;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name the variable returnVector to answer and change in other places

class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<pair<int,int>> valueIndexPair;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this code to

vector<pair<int, int>> valueIndexPair;

public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<pair<int,int>> valueIndexPair;
vector<int> returnVector;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the variable name returnVector to answer and also, change in other places where returnVector has been used. Additionally, fix the indentation.

vector<int> twoSum(vector<int>& nums, int target) {
vector<pair<int,int>> valueIndexPair;
vector<int> returnVector;
int index1, index2, sum;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the indentation.

int index1, index2, sum;

for(int k = 0; k < nums.size(); k++) {
valueIndexPair.push_back(pair<int,int>(nums[k], k));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this code to

valueIndexPair.push_back(pair<int, int>(nums[k], k));


sort(valueIndexPair.begin(), valueIndexPair.end());

index1 = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation

sort(valueIndexPair.begin(), valueIndexPair.end());

index1 = 0;
index2 = valueIndexPair.size() - 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation

while(index1 < index2) {
sum = valueIndexPair[index1].first + valueIndexPair[index2].first;

if(sum == target)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation

@Tahanima Tahanima added the needs work Need to make changes label Aug 11, 2021
@r8025n
Copy link
Contributor Author

r8025n commented Aug 13, 2021

HI,
Thank you for your feedback. I have addressed the requested changes, please review.

@r8025n r8025n requested a review from Tahanima August 13, 2021 07:35
Copy link
Owner

@Tahanima Tahanima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @r8025n
Please fix all the indentation issues.

public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<pair<int, int>> valueIndexPair;
vector<int> answer;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix the indentation.

vector<int> twoSum(vector<int>& nums, int target) {
vector<pair<int, int>> valueIndexPair;
vector<int> answer;
int index1, index2, sum;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix the indentation.


sort(valueIndexPair.begin(), valueIndexPair.end());

index1 = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix the indentation.

sort(valueIndexPair.begin(), valueIndexPair.end());

index1 = 0;
index2 = valueIndexPair.size() - 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix the indentation.

else
index2--;
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix the indentation of the if-else block.

@r8025n
Copy link
Contributor Author

r8025n commented Aug 15, 2021

Hi @Tahanima
I am kind of lost now, could you please help me out and point me to the right direction? As your recent requested changes are suggesting there are indentation issues in my code but in my forked repo the code looks okay. What am I missing here?

What I did so far:

  1. Opened a pull request.
  2. Some changes were requested by you.
  3. Addressed the requested changes in my local git repo, updated my repo with the original upstream repo by fetching and merging, then pushed them to my forked repo.
  4. And now as you addressed some indentation issues, as I visited my fork repo they seems fine there!!

So did I miss any steps after pushing the first requested changes to my forked repo?

@Tahanima Tahanima removed the needs work Need to make changes label Aug 17, 2021
Copy link
Owner

@Tahanima Tahanima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@r8025n I get your point. No worries. I'll fix the indentation issue (if there is any) after merging. Keep up the good work! 😃

@Tahanima Tahanima merged commit c67a778 into Tahanima:main Aug 17, 2021
@r8025n
Copy link
Contributor Author

r8025n commented Aug 18, 2021

Thank You :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add LeetCode-1. Two SUM, LeetCode-167. Two Sum II
2 participants