Skip to content

Conversation

@Chintha-vardhan
Copy link

  • Added folder Two_Sum with Solution.java
  • Updated index.md with problem link

@github-actions github-actions bot requested a review from iamwatchdogs October 12, 2025 16:43
@github-actions
Copy link

👋 @Chintha-vardhan
Thank you for raising your pull request.
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.

@github-actions github-actions bot added the hacktoberfest Opted for hacktoberfest label Oct 12, 2025
Copy link
Contributor

@iamwatchdogs iamwatchdogs left a comment

Choose a reason for hiding this comment

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

Please make the suggested changes to approve the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert the changes for this file. These changes will be updated automatically by the automation scripts when your PR is successfully merged.

@@ -0,0 +1,15 @@
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a good practice to use only imports that are necessary.

Suggested change
import java.util.*;
import java.util.HashMap;
import java.util.Map;

Comment on lines +3 to +15
class Solution {
public int[] twoSum(int[] nums, int target) {
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < nums.length; i++) {
int complement = target - nums[i];
if (map.containsKey(complement)) {
return new int[]{map.get(complement), i};
}
map.put(nums[i], i);
}
return new int[]{};
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please format your code to pass the linting checks.

Suggested change
class Solution {
public int[] twoSum(int[] nums, int target) {
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < nums.length; i++) {
int complement = target - nums[i];
if (map.containsKey(complement)) {
return new int[]{map.get(complement), i};
}
map.put(nums[i], i);
}
return new int[]{};
}
}
class Solution {
public int[] twoSum(int[] nums, int target) {
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < nums.length; i++) {
int complement = target - nums[i];
if (map.containsKey(complement)) {
return new int[] {map.get(complement), i};
}
map.put(nums[i], i);
}
return new int[] {};
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest Opted for hacktoberfest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants