-
-
Notifications
You must be signed in to change notification settings - Fork 195
[박종훈] 12주차 답안 제출 #187
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
[박종훈] 12주차 답안 제출 #187
Conversation
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.
public int lengthOfLIS(int[] nums) { | ||
ArrayList<Integer> subsequence = new ArrayList<>(); | ||
|
||
for (int current : nums) { | ||
// Collections.binarySearch : 목록에 포함된 경우 검색 키의 인덱스, 그렇지 않으면 (-(삽입점) - 1) 을 반환함. | ||
int pos = Collections.binarySearch(subsequence, current); | ||
if (pos < 0) pos = -(pos + 1); | ||
if (pos >= subsequence.size()) { | ||
subsequence.add(current); | ||
} else { | ||
subsequence.set(pos, current); | ||
} | ||
} | ||
|
||
return subsequence.size(); | ||
} |
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.
와, 종훈님의 이 풀이를 보고 와 이렇게 접근할 수도 있구나 충격을 받았습니다. 덕분에 이 문제를 다시 풀고 알고달레에 풀이 5와 풀이 6을 추가하게 되었네요. 신선한 영감을 주셔서 감사합니다! 🙏
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.
@DaleSeo 칭찬 감사드립니다 : ) 🥰
Longest Increasing Subsequence
Unique Paths
Longest Common Subsequence
Maximum Subarray
Jump Game