Skip to content

Commit 5978e54

Browse files
committed
Runtime: 80 ms (Top 65.60%) | Memory: 42.1 MB (Top 90.67%)
1 parent 2e60a28 commit 5978e54

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/algorithms/U/Univalued Binary Tree/Univalued Binary Tree.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
// Runtime: 80 ms (Top 65.60%) | Memory: 42.1 MB (Top 90.67%)
12
var isUnivalTree = function(root) {
23
if (!root) {
34
return false;
45
}
5-
6+
67
const prev = root.val;
78
const nodes = [root];
8-
9+
910
for (const node of nodes) {
1011
if (node.val !== prev) {
1112
return false;
@@ -22,4 +23,4 @@ var isUnivalTree = function(root) {
2223

2324
return true;
2425
};
25-
```
26+
```

0 commit comments

Comments
 (0)