Skip to content

[WEEK11] 최준호#48

Open
raejun92 wants to merge 1 commit into
mainfrom
raejun
Open

[WEEK11] 최준호#48
raejun92 wants to merge 1 commit into
mainfrom
raejun

Conversation

@raejun92
Copy link
Copy Markdown
Collaborator

이렇게 풀었어요

1. 다음큰숫자

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

1) 복잡도 계산

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

2) 접근 아이디어

  1. n의 1의 개수를 구하는 findOneCount 함수를 정의했다.
  2. n보다 큰 수를 하나씩 증가시키면서, findOneCount 함수로 1의 개수를 구해서, n의 1의 개수와 비교했다.
  3. 만약 두 개수가 같으면, 그 수를 반환했다.

3) 회고

처음에는 n의 이진수를 구해서 이진수를 가지고 구해보려고 했는데, 깊은 생각이 요구될 것 같아 그냥 하나씩 증가시키면서 구하는 방법으로 풀이했다.



2. 숫자의표현

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

1) 복잡도 계산

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

2) 접근 아이디어

  1. n이 1인 경우에는 1을 반환했다.
  2. n의 절반부터 0까지 루프를 돌면서, i부터 0까지 루프를 돌면서, sum에 j를 더했다.
  3. 만약 sum이 n보다 크면, 내부 루프를 종료했다.
  4. 만약 sum이 n과 같으면, answer를 1 증가시키고, 내부 루프를 종료했다.
  5. 루프가 끝난 후에는 answer를 반환했다.

3) 회고

천장에서 아래로 내려오면서 더하는 방식으로 풀이했는데 n이 1인 경우 예외 처리를 찾지 못해서 오래 걸렸다. DP로 풀이하는 방법도 있을 것 같고, for문은 한 번만 도는 방법도 있을 것 같은데 한 번 찾아봐야겠다.



@github-actions github-actions Bot requested review from doitchuu and sik9252 April 19, 2026 13:27
@LeeBaeJin LeeBaeJin self-requested a review April 20, 2026 08:27
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.

수고많으셨습니다!

Comment thread raejun/다음큰숫자.js

let findNum = n + 1;

while (42) {
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.

42 무릎탁 칩니다

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.

센스 👍

Comment thread raejun/숫자의표현.js
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.

오 이렇게 접근하는 방법은 생각 못해봤는데, 한 수 배웠습니다!

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.

고생하셨습니다 👍

Comment thread raejun/숫자의표현.js
function solution(n) {
var answer = 1;

if (n === 1) return 1;
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.

얼리 리턴 좋네요 👍

Comment thread raejun/다음큰숫자.js
.toString(2)
.split("")
.filter((n) => n === "1").length;
};
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.

ㅠㅠ 일이 많아서 리뷰 까먹고 있었네요... 고생하셨습니다!

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