-
Notifications
You must be signed in to change notification settings - Fork 0
LeetCode15 Solved #59
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
base: master
Are you sure you want to change the base?
Conversation
| int rIdx = nums.length - 1; | ||
| for(int i = 0; i < nums.length - 2; i++) { | ||
| pick = nums[i]; | ||
| target = 0 - pick; // pick + target = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to write 0-pick. -pick is clear enough.
Test1/src/leetcode/LeetCode15.java
Outdated
| List<Integer> list = new ArrayList<Integer>(); | ||
| list.add(nums[i]); | ||
| list.add(nums[l]); | ||
| list.add(nums[r]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider:
new ArrayList<>(Arrays.asList(nums[i], nums[l], nums[r]));
| resultAllList.add(list); | ||
| if(nums[i] == nums[l] && nums[l] == nums[r]) { | ||
| rIdx--; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the condition is like this. Can you explain your thought of this if-condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also thinking that I thought wrong.
I just solved so many only zeros case by using this.
But i think this is the wrong way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only 3 zeros case pass this if phrase.
what i thought at first was, if I delete one zero from the main arr, maybe it will reduce finding every case.
Then for this, I would add set that have index of one zero, and if set has that index pass it.
how about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.

Time Complexity : O(NM)