Skip to content

Instantly share code, notes, and snippets.

@songz
Created October 20, 2017 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save songz/a1d1c05b10cf72b16cb65a1d661bc9f4 to your computer and use it in GitHub Desktop.
Save songz/a1d1c05b10cf72b16cb65a1d661bc9f4 to your computer and use it in GitHub Desktop.
Biggest children
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