-
Notifications
You must be signed in to change notification settings - Fork 5
240516 김우정 0x02 풀이 #3
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
Conversation
| int n = scanner.nextInt(); | ||
| scanner.close(); | ||
|
|
||
| StringBuilder output = new 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.
StringBuilder 라는 객체를 처음 봤는데
이게 append 메소드가 String객체의 += 연산자보다 엄청 빠르다고 하더라고요!
저도 이제 이거로 알고리즘 풀어야 할듯 하네요
| StringBuilder line = new StringBuilder(); | ||
|
|
||
| for (int row = 0; row < 2 * n - 1; row++) { | ||
| line.setLength(0); |
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.
저같은 경우는 for 문이 시작할 때마다 String 객체를 생성 했는데 우정님은 line.setLength(0)을 함으로써 기존 객체를 재사용하는 게 시간적으로 더 효과적이겠네요. 하나 더 배웠습니다. 감사합니다!
|
|
||
| return new Pair(max, index+1); | ||
| } | ||
| } |
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.
혹시 클래스를 사용하여 푸신 이유가 따로 있으실까요?
이점이 따로 있다면 알려주시면 감사하겠습니다!
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.
그러게요.. 그냥 아무 생각없이 자연스럽게 함수로 해야겠다는 생각을 했었는데 아마도 배열과 관련된 함수가 최댓값을 찾는 함수, 최솟값을 찾는 함수 등 여러가지가 구현될 수 있으니까 당연하게 다른 기능들과 추가되기 쉽게 당연하게 함수들로 만들어야겠다..라고 생각했던 것 같아요! 지금 문제에서는 다른 분들 코드를 확인했더니 그냥 main에서 하는게 가독성도 좋고 깔끔하겠더라구요!
240516 김우정 0x02 풀이