摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following is not: 1 / \ 2 2 \ \ 3 3Note:Bonus points if you could solve it both recursively and iterati... 阅读全文
posted @ 2013-10-22 20:53 昱铭 阅读(175) 评论(0) 推荐(0)
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST.============================================================================================If you would have to choose an array element to be the root of a balanced BST, which element would you pick? Th 阅读全文
posted @ 2013-10-22 17:45 昱铭 阅读(164) 评论(0) 推荐(0)
摘要: Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at 阅读全文
posted @ 2013-10-22 17:23 昱铭 阅读(113) 评论(0) 推荐(0)