-
Notifications
You must be signed in to change notification settings - Fork 21
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
정유경 / 10월 4주차 / 월 #296
base: main
Are you sure you want to change the base?
정유경 / 10월 4주차 / 월 #296
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.
고생하셨습니다.!
|
||
}// end main | ||
|
||
private static int answer(int k) { |
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.
부모, 자식을 카운팅하는 코드가 거의 일치하는데 answer이라는 메서드 두 번 호출로 각각의 값을 반환시켜서 처리하는건 어떨까요?
answer.append(t); | ||
|
||
//기저조건 | ||
if(answer.toString().equals(sb.toString())) { |
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.
t.equals로 스트링 비교 처리가 깔끔할 거 같은데
혹시 StringBuilder를 쓰시는 이유가 있나요?
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.
모든 경우에 equals를 사용해서 equals 비용이 무조건 O(n)이라고 생각해서 문제가 되지 않을까 했는데 자바7부터 길이가 다르면 false를 리턴하는 빠른 처리가 생겼었다네요..
하나 알아갑니다^^
@IntrinsicCandidate
public static boolean equals(byte[] value, byte[] other) {
if (value.length == other.length) {
for (int i = 0; i < value.length; i++) {
if (value[i] != other[i]) {
return false;
}
}
return true;
}
return false;
}
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.
유경님 요즘 폼이 장난이 아니시네요! 고생하셨어요~~❤❤
태호님 감사드립니다! 함께 힘내서 알고리즘 뿌셔보아요! |
항상 좋은 코드 잘 구경하고 가요! 예준님이 발견하신 것처럼 길이 비교를 통해 boolean 값을 리턴하는 구문은 처음 보네요. |
🎈boj 12919 - A와 B2
🗨 해결방법 :
S -> T 가 아닌 T-> S가 되는 방법을 생각하여 풀었습니다.
📝메모 :
S -> T 가 되는 경우로 생각하여 문제를 풀면 시간초과 난다.
✔코드 :
🎈boj 10159 - 저울
🗨 해결방법 :
bfs를 통해 부모노드수 + 자식노드의수 + 자신의 수를 구하여 해결하였다.
📝메모 :
✔코드 :