Created
October 20, 2017 01:33
-
-
Save songz/a1d1c05b10cf72b16cb65a1d661bc9f4 to your computer and use it in GitHub Desktop.
Biggest children
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bfs = (lev=[], prolific) => { | |
if(!lev.length) return prolific; | |
const n = lev.shift(); | |
if(!prolific || prolific.children.length > n.children.length) | |
prolific = n; | |
return bfs(lev.concat(n.children)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment