Skip to content

Conversation

gitsunmin
Copy link
Contributor

@gitsunmin gitsunmin commented Nov 22, 2024

답안 제출 문제

체크 리스트

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 Status를 In Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@gitsunmin gitsunmin requested a review from EgonD3V November 22, 2024 22:02
@gitsunmin gitsunmin self-assigned this Nov 22, 2024
@gitsunmin gitsunmin requested a review from a team as a code owner November 22, 2024 22:02
@github-actions github-actions bot added the ts label Nov 22, 2024
Copy link
Contributor

@HC-kang HC-kang left a comment

Choose a reason for hiding this comment

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

@gitsunmin 님, 15주 간 마지막 한 주까지 고생 많으셨습니다!

/**
* https://leetcode.com/problems/longest-palindromic-substring/
* time complexity : O(n)
* space complexity : O(n^2)
Copy link
Contributor

Choose a reason for hiding this comment

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

시간, 공간 복잡도를 이렇게 판단하신 이유가 있으실까요?
제 생각에 시간 복잡도는 최대 N * N/2O(n^2) 이고 공간복잡도는 리턴값을 고려하더라도 O(n), 제외한다면 O(1)로 볼 수 있을 것 같아서요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

이렇게 계산했어요!
• for 루프: 문자열 길이 n에 따라 n번 반복 → O(n).
• 팰린드롬 확장: 각 중심에서 최대 문자열 길이만큼 확장 → O(n).
• 전체 시간 복잡도: O(n) × O(n) = O(n²).

최악의 경우, 모든 중심에서 최대 확장되므로 O(n²)

function longestPalindrome(s: string): string {
if (s.length <= 1) return s;

let longestPalindromeStartIndex = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

중요한 사항은 아닙니다!
변수명이 조금 지나친 것 같습니다.. 읽기 어려워요ㅠㅠ


function isValidBST(root: TreeNode | null): boolean {

return validate(root, -Infinity, Infinity);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍


function isSameTree(p: TreeNode | null, q: TreeNode | null): boolean {
if (!p && !q) return true;
if (!p || !q || p.val !== q.val) return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

재귀함수의 early return에서 조심할 점이 있다면 단축평가에서 손해보는 점인 것 같습니다. 그리고 if-else가 아니라 if문 단독으로 쓰는 경우, 개인적으로 각 if 문들의 조건이 무조건 독립적이도록 짜면 어떨까 싶습니다.

Copy link
Contributor

@EgonD3V EgonD3V left a comment

Choose a reason for hiding this comment

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

15주간 수고 많으셨습니다. 제 기억으로 선민님께서 오리엔테이션에 참가하지 못하셨던 것같은데, 다른 분들보다 적응에 어려우셨을텐데도 완주하신 점 참 멋지다고 생각합니다.

@gitsunmin gitsunmin merged commit 010dc6d into DaleStudy:main Nov 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants