Skip to content

Conversation

@sangilji
Copy link
Collaborator

@sangilji sangilji commented Feb 26, 2023

주석달아놨으니 궁금한건 말로 설명하겠음...

Comment on lines +13 to +16
Map<String, Integer> map = new HashMap<>(); //차와 현재 위치를 저장할 맵
for (int i = 1; i <= n; i++) {
map.put(br.readLine(), i);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 해쉬맵으로 푸는 문제였어요? 짱짱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;
}
}
Copy link
Collaborator

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]);
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 설명해주실 수 있나유

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]; //문자열도 현재 문자열 추가
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

갓.... 발표 요청하겠습니다..


System.out.println(count); //
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

같은 풀이입니다

@InHyeok-J InHyeok-J self-requested a review February 28, 2023 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants