Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example, Given n = 3, your program should return all... Read More
posted @ 2014-08-06 21:56 Xylophone Views(171) Comments(0) Diggs(0)
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example, Given: s1 = "aabcc", s2 = "dbbca",When s3 = "aadbbcbcac", re... Read More
posted @ 2014-08-06 20:39 Xylophone Views(120) Comments(0) Diggs(0)
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n... Read More
posted @ 2014-08-06 11:04 Xylophone Views(106) Comments(0) Diggs(0)
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note: A solution using O(n) space is... Read More
posted @ 2014-08-06 10:39 Xylophone Views(172) Comments(0) Diggs(0)