Skip to content

[WEEK10] 최준호#44

Merged
raejun92 merged 1 commit into
mainfrom
raejun
Apr 19, 2026
Merged

[WEEK10] 최준호#44
raejun92 merged 1 commit into
mainfrom
raejun

Conversation

@raejun92
Copy link
Copy Markdown
Collaborator

이렇게 풀었어요

1. 이진변환반복하기

  • 문제를 풀었어요.
  • 풀이 시간 : 10분

1) 복잡도 계산

  • 시간 복잡도: O(n log n)
  • 공간 복잡도: O(1)

2) 접근 아이디어

  1. 문자열 s가 "1"이 될 때까지 반복하면서, 문자열 s에서 "0"을 제거하고, 남은 "1"의 개수를 구했다.
  2. "1"의 개수를 이진수 문자열로 변환했다.
  3. 반복할 때마다 제거한 "0"의 개수를 zero에 더했고, 반복한 횟수를 count에 더했다.
  4. 문자열 s가 "1"이 되면, [count, zero]를 반환했다.

3) 회고

문제에서 요구사항을 그대로 구현하면 되는 문제였다. 문자열 메서드를 오랜만에 사용해서 조금 헷갈렸다.



2. 최솟값만들기

  • 문제를 풀었어요.
  • 풀이 시간 : 4분

1) 복잡도 계산

  • 시간 복잡도: O(n log n)
  • 공간 복잡도: O(1)

2) 접근 아이디어

  1. 배열 A는 오름차순으로 정렬하고, 배열 B는 내림차순으로 정렬했다.
  2. 배열 A와 배열 B의 요소들을 순회하면서, 각 요소들을 곱해서 answer에 더했다.

3) 회고

눈치껏 최솟값과 최댓값을 곱하는 방식으로 풀이했다. 근데 왜 그게 최솟값이 되는지는 잘 모르겠다.



const len = s.length;

s = s.replaceAll("0", "");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

와 replaceAll은 생각지도 못했네요


A.sort((a, b) => a - b);
B.sort((a, b) => b - a);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

javascript sort함수로 역순을 이렇게 표현할 수 있군요

Copy link
Copy Markdown
Collaborator

@LeeBaeJin LeeBaeJin left a comment

Choose a reason for hiding this comment

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

좋은 공부가 되었습니다! 수고많으셨습니다!

Copy link
Copy Markdown
Member

@doitchuu doitchuu left a comment

Choose a reason for hiding this comment

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

문제 풀이가 깔끔해서 잘읽혔어요! 고생하셨습니다

s = oneCount.toString(2);

zero += len - oneCount;
count++;
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.

변수 가독성이 좋네요 😄

Copy link
Copy Markdown
Collaborator

@sik9252 sik9252 left a comment

Choose a reason for hiding this comment

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

replaceAll을 쓰는 방법도 있군요~! 왜 안 떠올랐지 ㅠ 역시 잘 푸셨네요 고생하셨습니다!

@raejun92 raejun92 merged commit be63beb into main Apr 19, 2026
1 check passed
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.

4 participants