摘要: Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown ... 阅读全文
posted @ 2015-07-12 18:53 Maydow 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()... 阅读全文
posted @ 2015-07-12 17:41 Maydow 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1思路:利用temp进行交换,采用递归从顶至下,终止条件本身为空或者是叶子节点。... 阅读全文
posted @ 2015-07-12 16:55 Maydow 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Given a sorted integer array without duplicates, return the summary of its ranges.For example, given[0,1,2,4,5,7], return["0->2","4->5","7"].思路:采用双指针 ... 阅读全文
posted @ 2015-07-12 16:31 Maydow 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Given an integer, write a function to determine if it is a power of two.判断一个数是不是2的幂。思路,找出该数中二进制位1的个数时间复杂度:O(n)代码: public boolean isPowerOfTwo(int n... 阅读全文
posted @ 2015-07-12 15:46 Maydow 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front o... 阅读全文
posted @ 2015-07-12 15:31 Maydow 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: ... 阅读全文
posted @ 2015-07-12 14:44 Maydow 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 二叉树 在计算机科学中,二叉树是每个节点最多有两个子树的树结构。通常子树被称作“左子树”(left subtree)和“右子树”(right subtree)。二叉树常被用于实现二叉查找树和二叉堆。 二叉树的每个结点至多只有二棵子树(不存在度大于2的结点),二叉树的子树有左右之分,次序不能颠倒。二叉 阅读全文
posted @ 2015-07-12 13:56 Maydow 阅读(299) 评论(0) 推荐(0) 编辑