https://leetcode.com/problems/univalued-binary-tree/
| 9 | * https://leetcode.com/problems/univalued-binary-tree/ |
| 10 | */ |
| 11 | public class Sanghoo { |
| 12 | |
| 13 | public boolean isUnivalTree(TreeNode root) { |
| 14 | Queue<TreeNode> q = new ArrayDeque<>(); |
| 15 | int value = 0; |
| 16 | |
| 17 | q.add(root); |
| 18 | value = root.val; |
| 19 | |
| 20 | while(!q.isEmpty()) { |
| 21 | TreeNode node = q.poll(); |
| 22 | |
| 23 | if(value != root.val) return false; |
| 24 | |
| 25 | if(node.left != null) q.add(node.left); |
| 26 | if(node.right != null) q.add(node.right); |
| 27 | } |
| 28 | |
| 29 | return true; |
| 30 | } |
| 31 | |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected