2015年3月11日

Search for a Range

摘要: 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 complexi... 阅读全文

posted @ 2015-03-11 21:42 zhouzhou0615 阅读(195) 评论(0) 推荐(0) 编辑

Sort List

摘要: Sort List问题:Sort a linked list inO(nlogn) time using constant space complexity.思路: 归并排序我的代码:public class Solution { public ListNode sortList(ListN... 阅读全文

posted @ 2015-03-11 20:31 zhouzhou0615 阅读(152) 评论(0) 推荐(0) 编辑

Intersection of Two Linked Lists

摘要: Intersection of Two Linked Lists问题:Write a program to find the node at which the intersection of two singly linked lists begins.思路: 追击问题我的代码:public c... 阅读全文

posted @ 2015-03-11 19:58 zhouzhou0615 阅读(125) 评论(0) 推荐(0) 编辑

Length of Last Word

摘要: Length of Last Word问题:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the strin... 阅读全文

posted @ 2015-03-11 19:39 zhouzhou0615 阅读(172) 评论(0) 推荐(0) 编辑

Longest Consecutive Sequence

摘要: Longest Consecutive Sequence问题:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.思路: HashSet进行存储我的代码:... 阅读全文

posted @ 2015-03-11 19:30 zhouzhou0615 阅读(119) 评论(0) 推荐(0) 编辑

Reorder List

摘要: Reorder List问题:Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' ... 阅读全文

posted @ 2015-03-11 16:08 zhouzhou0615 阅读(145) 评论(0) 推荐(0) 编辑

Remove Nth Node From End of List

摘要: Remove Nth Node From End of List问题:Given a linked list, remove thenthnode from the end of list and return its head.我的思路: 使用HashMap存储好位置我的代码:public cl... 阅读全文

posted @ 2015-03-11 15:37 zhouzhou0615 阅读(181) 评论(0) 推荐(0) 编辑

Sum Root to Leaf Numbers

摘要: Sum Root to Leaf Numbers问题:Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-t... 阅读全文

posted @ 2015-03-11 15:21 zhouzhou0615 阅读(134) 评论(0) 推荐(0) 编辑

Reverse Integer

摘要: Reverse Integer问题:Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321click to show spoilers.Have you thought about... 阅读全文

posted @ 2015-03-11 11:23 zhouzhou0615 阅读(104) 评论(0) 推荐(0) 编辑

Palindrome Number

摘要: Palindrome Number 问题: Determine whether an integer is a palindrome. Do this without extra space. 思路: 常用的进制遍历方法 while(num != 0) { remian = num % 进制; nu 阅读全文

posted @ 2015-03-11 10:57 zhouzhou0615 阅读(127) 评论(0) 推荐(0) 编辑

Binary Tree Level Order Traversal II

摘要: Binary Tree Level Order Traversal II问题:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, le... 阅读全文

posted @ 2015-03-11 08:49 zhouzhou0615 阅读(104) 评论(0) 推荐(0) 编辑

Path Sum

摘要: Path Sum问题:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the g... 阅读全文

posted @ 2015-03-11 08:26 zhouzhou0615 阅读(147) 评论(0) 推荐(0) 编辑

导航