Helpers
Shared TreeNode for binary-tree problems.
- File
- TreeNode.java
- Path
- pkg5leetcode/common/TreeNode.java
- Lesson
- Back to the chapter
There is no in-browser runner. This is the file from the curriculum, unchanged.
1/**2 * Shared TreeNode for binary-tree problems.3 *4 * Learn once, reuse across Blind75 / Interview 150 / Top 100.5 *6 * Compile with a problem file:7 * javac pkg5leetcode/common/TreeNode.java pkg5leetcode/blind75/YourProblem.java8 * java -cp pkg5leetcode/common;pkg5leetcode/blind75 YourProblem9 */10public class TreeNode {11 public int val;12 public TreeNode left;13 public TreeNode right;14 15 public TreeNode() {}16 17 public TreeNode(int val) {18 this.val = val;19 }20 21 public TreeNode(int val, TreeNode left, TreeNode right) {22 this.val = val;23 this.left = left;24 this.right = right;25 }26}