Skip to content

Instantly share code, notes, and snippets.

@robconery
Created September 27, 2023 19:20
Show Gist options
  • Save robconery/121afe4a1164f28371319cb771a4adf2 to your computer and use it in GitHub Desktop.
Save robconery/121afe4a1164f28371319cb771a4adf2 to your computer and use it in GitHub Desktop.
Mission Skeet Binary Tree

This question is seemingly simple:

Decide if a tree is a binary tree

and then…

Decide if the tree is balanced

Another super common question you will likely be asked in one form or another. Interviewers just LOVE questions about binary tree traversal!

This question should take 30 minutes.

Some code to get you started:

//you can use an Array as a Stack or a Queue in ES6 as well
class TreeNode{
  constructor(val){
    this.value = val;

  }
  addRight(val){
    this.right = new TreeNode(val);
    return this.right;
  }
  addLeft(val){
    this.left = new TreeNode(val);
    return this.left;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment