Skip to content

Conversation

gwbaik9717
Copy link
Contributor

@gwbaik9717 gwbaik9717 commented Feb 9, 2025

답안 제출 문제

체크 리스트

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

@gwbaik9717 gwbaik9717 requested a review from KwonNayeon February 9, 2025 02:52
@gwbaik9717 gwbaik9717 self-assigned this Feb 9, 2025
@gwbaik9717 gwbaik9717 requested a review from a team as a code owner February 9, 2025 02:52
@github-actions github-actions bot added the js label Feb 9, 2025
Comment on lines +12 to +33
/**
* @param {TreeNode} root
* @return {TreeNode}
*/
var invertTree = function (root) {
const dfs = (current) => {
if (!current) {
return;
}

const temp = current.left;
current.left = current.right;
current.right = temp;

dfs(current.left);
dfs(current.right);
};

dfs(root);

return root;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

DFS와 재귀를 활용하면 더 깔끔한 코드로 구현할 수 있겠어요. 참고가 되었습니다. 감사합니다!

Comment on lines +1 to +2
// Time complexity: O(n)
// Space complexity: O(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

저도 거의 동일한 방식으로 풀었습니다! 표현하는 방식 등 여러가지로 파이썬과 다른 부분이 있어서 비교해서 보는 재미가 있었어요. 시간/공간 복잡도에 대한 설명을 추가해주시면 더 좋을 것 같습니다. 이번 주도 고생하셨습니다!

@gwbaik9717 gwbaik9717 merged commit b87290d into DaleStudy:main Feb 15, 2025
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.

2 participants