Skip to content

[soobing] WEEK01 Solution #1675

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

[soobing] WEEK01 Solution #1675

wants to merge 3 commits into from

Conversation

soobing
Copy link
Contributor

@soobing soobing commented Jul 20, 2025

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

Comment on lines +33 to +40
const dp = (i: number) => {
if (i < 0) return 0;
if (memo.has(i)) return memo.get(i);

const res = Math.max(dp(i - 1)!, dp(i - 2)! + nums[i]);
memo.set(i, res);
return res;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

현재 ! 연산자를 사용해도 코딩 테스트에선 문제는 없지만, 혹시 dp 함수의 반환 타입을 명시적으로 number로 지정해보는 건 어떨까요? const dp = (i: number): number => {
그렇게 하면 non-null assertion 없이도 컴파일러가 타입을 안전하게 추론해줘서 더 명확해질 것 같아요!!😊

Comment on lines +37 to +40
if (this.heap.length === 0) return undefined;
const min = this.heap[0];
const end = this.heap.pop();
if (this.heap.length > 0 && end !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if (this.heap.length === 0) return undefined;로 힙에 값이 없으면 undefined를 반환하도록 되어 있으니 end !== undefined는 없어도 되지 않을까요?

* 공간 복잡도: O(N)
*/
class MinHeap {
heap: [number, number][] = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

[number, number][] 이 형식이 뭔지 궁금합니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Solving
Development

Successfully merging this pull request may close these issues.

2 participants