摘要:
题目:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For e... 阅读全文
摘要:
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Solution:If you would have to choose an array element... 阅读全文
摘要:
题目:Given acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, exc... 阅读全文
摘要:
题目:Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["... 阅读全文
摘要:
题目:Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's t... 阅读全文
摘要:
Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes. The lowest common ancestor is the node with larg 阅读全文
摘要:
题目:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.AnalysisThis problem can be solved by using B... 阅读全文
摘要:
题目:Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which ... 阅读全文