Skip to content

week2/twalla#11

Merged
twalla26 merged 7 commits into
dandi-swm:mainfrom
twalla26:main
Jul 19, 2026
Merged

week2/twalla#11
twalla26 merged 7 commits into
dandi-swm:mainfrom
twalla26:main

Conversation

@twalla26

@twalla26 twalla26 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

✏️ 2주차

해결한 문제

  • 멀리 뛰기
  • 섬 연결하기
  • 괄호 회전하기
  • 기지국 설치

@twalla26 twalla26 self-assigned this Jul 13, 2026
@twalla26 twalla26 added the ✏️ 문제 풀었어요! 문제 풀이 PR에 부착되는 라벨입니다. label Jul 13, 2026
@twalla26 twalla26 linked an issue Jul 13, 2026 that may be closed by this pull request
@twalla26
twalla26 marked this pull request as ready for review July 18, 2026 14:07
@twalla26
twalla26 requested review from Vryez11 and nonani July 18, 2026 14:07

@Vryez11 Vryez11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 💯


boolean check(String s) {

Stack<Character> stack = new Stack<>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

제가 알기로는 Stack 클래스 자체가 레거시여서 사용하지 않는 걸로 알고 있습니다!

그래서 Dequeue를 이용해서 push, poll 메서드로 Stack을 구현하는 걸로 알고있어용

아마도? synchronized 를 항상해서 성능문제 였던 걸로 기억하는데 한 번 찾아 보시면 좋을 것 같아요!


int cnt = 0;
for (int i = 0; i < N; i++) {
String moved = s.substring(i, N) + s.substring(0, i);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

저는 Queue 를 이용해서 앞에서 빼고, 뒤에 더하는 방식으로 문제를 풀었었는데

substring 방식도 있겠네요!

약간, 근데 저는 사실 뭔가 새로운 객체를 생성안하고 문제를 풀 수 있지 않을까 생각했는데 떠오르지는 않더라구요.
그래서 다른 방법을 좀 찾아봤는데

  1. string 자체를 2개를 더하는 방법으로 윈도우 슬라이드 느낌으로 검사 하기 -> 이게 진짜 말이 안되는 듯요.
  2. 나머지 연산을 통해 인덱스로 접근하기
    for (int j = 0; j < s.length(); j++) {
          char c = s.charAt((start + j) % s.length());
    }

위의 두 방법이 있어서 약간 구석에 저장해놨다가 써먹어봐요 ㅋㅋ

Comment on lines +39 to +42
cache = new long[n + 1];
Arrays.fill(cache, -1);

long answer = fibo(n);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

재귀 형식으로 푼 이유가 있을까요?

저는 반복문으로 풀었는데 뭔가 Arrays.fill() 이 내부적으로 최적화 된다고 해도 결국 모든 값을 초기화 해야 하는 것이고, 재귀적으로 하게 되면 새로운 스택?이 쌓이는 거니까 뭔가 이유가 있는 것인지 궁금했습니당

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

피보나치 하면 바로 재귀가 생각났는데, 반복문으로 푸는 방법도 있죠!

Comment on lines +30 to +41
if (s.charAt(start) != '{') {
start += 1;
continue;
}

int end = start;
while (s.charAt(end) != '}') {
end += 1;
}

String[] scope = s.substring(start + 1, end).split(",");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

정규식 파싱 한 번 익혀두면 여러모로 편하더라구요 ㅋㅋ

@nonani nonani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@twalla26
twalla26 merged commit da75400 into dandi-swm:main Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✏️ 문제 풀었어요! 문제 풀이 PR에 부착되는 라벨입니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Week 2] 문제 선정

3 participants