Toggle navigation
Marcy Blog
Home
About
Prepare Code Interview
Tags
Marcy Blog
Failed to be a geek
Problem: Verify Balanced Binary Tree
Question Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: A binary tree in which the depth of the two subtrees of every nod...
Problem: Populating Next Right Pointers in Each Node II
Question Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If there is n...
Problem: Binary Tree Zigzag Order Level Traversal
Question Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to the left for the next level and alternate between). For example:...
Problem: Binary Tree Level Order Traversal
Question Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \...
Problem: Lowest Common Ancestor of a Binary Tree
Question Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between...
Problem: Lowest Common Ancestor of a Binary Search Trees
Question Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is def...
Problem: Merge Two Trees
Question Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a ne...
Problem: Symmtric Tree
Question Given a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / ...
Problem: Sum Root to Leaf Numbers
Question Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. ...
Problem: Maximum Width of Binary Tree
Question Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the same structure as a fu...
← Newer Posts
Older Posts →
FEATURED TAGS
Life
Ruby on Rails
Project Management
Agile
Ruby
OOP
Design Patterns
ABOUT ME
To be a top coder, a proud father, and a better man