MCPcopy Create free account
hub / github.com/ROUTINE-STUDY/Algorithm / Sanghoo

Class Sanghoo

LeetCode/DFS/94. Binary Tree Inorder Traversal/Sanghoo.java:6–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import java.util.List;
5
6public class Sanghoo {
7
8 // return 을 위한 인스턴스 변수 선언
9 public List<Integer> res = new ArrayList<>();
10
11 public List<Integer> inorderTraversal(TreeNode root) {
12 if(root == null) return res;
13
14 if(root.left != null) inorderTraversal(root.left);
15 res.add(root.val); // 중위 순회이므로 왼쪽 노드 체크 후 값 추가
16 if(root.right != null) inorderTraversal(root.right);
17
18 return res;
19 }
20
21}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected