Skip to content

Commit 1b7a2d0

Browse files
authored
Update 310-minimum-height-trees.js
1 parent 71678f3 commit 1b7a2d0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

310-minimum-height-trees.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @return {number[]}
55
*/
66
const findMinHeightTrees = function (n, edges) {
7-
const hash = {}
7+
const graph = {}
88

99
for(const [u, v] of edges) {
1010
if(graph[u] == null) graph[u] = new Set()
@@ -15,15 +15,15 @@ const findMinHeightTrees = function (n, edges) {
1515

1616
let q = []
1717
for(let i = 0; i < n; i++) {
18-
if(hash[i].size === 1) q.push(i)
18+
if(graph[i].size === 1) q.push(i)
1919
}
2020

2121
while(n > 2) {
2222
const size = q.length, nxt = []
2323
n -= size
2424
for(let i = 0; i < size; i++) {
2525
const cur = q[i]
26-
for(const e of (hash[cur] || [])) {
26+
for(const e of (graph[cur] || [])) {
2727
graph[e].delete(cur)
2828
if(graph[e].size === 1) nxt.push(e)
2929
}

0 commit comments

Comments
 (0)