-
Notifications
You must be signed in to change notification settings - Fork 0
LeetCode39 done #70
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?
LeetCode39 done #70
Conversation
bigelephant29
left a comment
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.
Overall I think you can think about any potential heuristic cut.
|
|
||
| findAnswer(candidates, new ArrayList<>(), target); | ||
|
|
||
| return answerList; |
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.
It's not a good pattern to return a "global" list.
I think you could just declare an answerList inside this function, not at line 12.
| } | ||
| } | ||
|
|
||
| private boolean hasReverseOrder(List<Integer> answer, int factor) { |
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.
Not quite sure what this is for. Can you explain this a bit?
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.
This functions is for removing duplicated case
For example,
When the conditions are following case
Input: candidates = [2,3,6,7], target = 7
Output: [[2,2,3],[7]]
{2,2,3}, {2,3,2}, {3,2,2} those three cases are all allowed.
To filter those cases, I make the hasReverseOrder method.
Anyway, How about Germany?
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 guess you can try to avoid duplicated cases at the first place, then you don't need to remove anything in your code.
Germany is good so far. I love it very much! It's a pretty chilling place and I feel very relaxed every day.
Time complexity : O(N^2)