Leetcode #366 Find Leaves of Binary Tree
I'll be using Depth-First Search to solve this question.
My approach is to:
Traverse and find all the leaf nodes.
Remove the leaf nodes until there's none left.
Link: Find Leaves of Binary Tree
var findLeaves = function(root) {
let leaf = [];
...
michelletanpy.hashnode.dev1 min read