Conversation
Comment on lines
+13
to
+16
| Map<String, Integer> map = new HashMap<>(); //차와 현재 위치를 저장할 맵 | ||
| for (int i = 1; i <= n; i++) { | ||
| map.put(br.readLine(), i); | ||
| } |
Collaborator
There was a problem hiding this comment.
아 해쉬맵으로 푸는 문제였어요? 짱짱bbb
Comment on lines
+37
to
+65
| Arrays.sort(ab); // 정렬 | ||
| Arrays.sort(cd); | ||
| long count = 0; | ||
| int start = 0; //ab의 시작지점 | ||
| int last = cd.length - 1; // cd의 시작지점 | ||
| while (start < n * n && last >= 0) { | ||
| int a = ab[start]; // 가장 작은 | ||
| int b = cd[last]; // 가장 큰 | ||
| if (a + b > 0) { // 합이 0보다 크면 | ||
| last--; // 큰 값 낮추기 | ||
| } else if (a + b < 0) { | ||
| start++; // 작은 값 낮추기 | ||
| } else { // 같으면 | ||
| int aCount = 0; | ||
| for (int i = start; i < ab.length; i++) { | ||
| if (a == ab[i]) { | ||
| aCount++; | ||
| } else { | ||
| break; | ||
| } | ||
| } | ||
| int bCount = 0; | ||
| for (int i = last; i >= 0; i--) { | ||
| if (b == cd[i]) { | ||
| bCount++; | ||
| } else { | ||
| break; | ||
| } | ||
| } |
Collaborator
There was a problem hiding this comment.
아... 이래서 정렬에 투포인터.. 배워갑니다 역시 갓상일,,
| System.out.println(sdp[idx]); | ||
| } | ||
| } | ||
| } |
eastsage
reviewed
Feb 28, 2023
Comment on lines
+22
to
+33
| if (tmp < dp[j]) { //만약 dp값이 더크면 | ||
| tmp = dp[j]; // tmp를 올려줌 | ||
| stmp = sdp[j]; // 문자열도 추가 | ||
| if (a[i].equals(b[j])){ // 만약 dp값을 설정해주었는데 같은 문자열이면 맥스값으로만 설정하고 넘어감 | ||
| continue; | ||
| } | ||
| } | ||
|
|
||
| if (a[i].equals(b[j])) { // 만약 같은 문자열이면 | ||
| dp[j] = tmp + 1; // 현재 최고 값인 tmp를 현재 문자열 위치에 tmp+1 | ||
| sdp[j] = stmp + b[j]; //문자열도 현재 문자열 추가 | ||
| } |
|
|
||
| System.out.println(count); // | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
주석달아놨으니 궁금한건 말로 설명하겠음...