- 博客(6)
- 收藏
- 关注
原创 [LeetCode]Lowest Common Ancestor of a Binary Tree
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 two nodes
2015-07-26 10:22:42 498
原创 [LeetCode]Implement Queue using Stacks
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 of queue.peek() -- Get the front element.empty(
2015-07-18 10:07:26 599
原创 [LeetCode]Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value
2015-07-18 10:00:58 630
原创 [LeetCode]Lowest Common Ancestor of a Binary Search Tree
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 defined betwee
2015-07-18 09:59:19 537
原创 [LeetCode]Power of Two
Given an integer, write a function to determine if it is a power of two. [思路] 1)考虑各种边界情况。输入是整型值,说明不用考虑2的负指数情况。 2)如果一个数是二的倍数,说明他的二进制形式只有一位是1。做好判断即可。 循环判断1的位数解法最容易想到。 Leetcode上有种解法,就是让n&n-1,如果n只含有一
2015-07-17 19:25:22 511
原创 [LeetCode]Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target is not found
2015-07-04 10:52:51 544
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人