항해99_코테스터디

[항해99]99클럽 코테 스터디 6일차 TIL + 깊이/너비 우선 탐색 (DFS/BFS)

아설아 2024. 6. 3. 01:22

 

1.  오늘의 문제 :  Invert Binary Tree

https://leetcode.com/problems/invert-binary-tree/

2.  풀이 

class Solution {
    public TreeNode invertTree(TreeNode root) {
        if(root == null) return root;
        TreeNode temp = root.left;
        root.left = root.right;
        root.right = temp;
        invertTree(root.left);
        invertTree(root.right);
        return root;
    }
}

https://devraphy.tistory.com/569

 

LeetCode 226(Invert Binary Tree, java)

0. 문제 https://leetcode.com/problems/invert-binary-tree/ Invert Binary Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제

devraphy.tistory.com

참고 했습니다. 두 개를 바꾸는 것은 알았는데 이걸 재귀로 어떻게 써야할지 모르겠더라고요... 재귀함수 문제를 더 풀어봐야할 것 같습니다.

 

 

#99클럽 #코딩테스트 준비 #개발자 취업 #항해99 #TIL