-
Notifications
You must be signed in to change notification settings - Fork 1
[6주차] 지상일 백준 문제 2002, 9252, 15486, 15565, 2616, 7453 풀이 #14
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: main
Are you sure you want to change the base?
Conversation
| Map<String, Integer> map = new HashMap<>(); //차와 현재 위치를 저장할 맵 | ||
| for (int i = 1; i <= n; i++) { | ||
| map.put(br.readLine(), i); | ||
| } |
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.
아 해쉬맵으로 푸는 문제였어요? 짱짱bbb
| 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; | ||
| } | ||
| } |
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.
아... 이래서 정렬에 투포인터.. 배워갑니다 역시 갓상일,,
| System.out.println(sdp[idx]); | ||
| } | ||
| } | ||
| } |
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.
이거 설명해주실 수 있나유
| 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]; //문자열도 현재 문자열 추가 | ||
| } |
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.
갓.... 발표 요청하겠습니다..
|
|
||
| System.out.println(count); // | ||
| } | ||
| } |
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.
같은 풀이입니다
주석달아놨으니 궁금한건 말로 설명하겠음...