摘要: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. Solution: Solution 2: Whenever the value o 阅读全文
posted @ 2014-11-29 10:52 LiBlog 阅读(168) 评论(0) 推荐(0)
摘要: Write a function to find the longest common prefix string amongst an array of strings.Solution: 1 public class Solution { 2 public String longestC... 阅读全文
posted @ 2014-11-29 10:36 LiBlog 阅读(137) 评论(0) 推荐(0)
摘要: Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After ... 阅读全文
posted @ 2014-11-29 10:26 LiBlog 阅读(119) 评论(0) 推荐(0)
摘要: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the c... 阅读全文
posted @ 2014-11-29 10:08 LiBlog 阅读(157) 评论(0) 推荐(0)
摘要: Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文
posted @ 2014-11-29 09:58 LiBlog 阅读(118) 评论(0) 推荐(0)
摘要: Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Update (2014-11-02):The s... 阅读全文
posted @ 2014-11-29 07:46 LiBlog 阅读(169) 评论(0) 推荐(0)
摘要: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with... 阅读全文
posted @ 2014-11-29 07:30 LiBlog 阅读(149) 评论(0) 推荐(0)
摘要: The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off ... 阅读全文
posted @ 2014-11-29 07:16 LiBlog 阅读(159) 评论(0) 推荐(0)
摘要: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word ... 阅读全文
posted @ 2014-11-29 06:34 LiBlog 阅读(129) 评论(0) 推荐(0)
摘要: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Solution:... 阅读全文
posted @ 2014-11-29 06:26 LiBlog 阅读(110) 评论(0) 推荐(0)
摘要: Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100".Solution: 1 public class Solution { 2 p... 阅读全文
posted @ 2014-11-29 06:20 LiBlog 阅读(141) 评论(0) 推荐(0)
摘要: Given a non-negative number represented as an array of digits, plus N to the number.The digits are stored such that the most significant digit is at t... 阅读全文
posted @ 2014-11-29 06:09 LiBlog 阅读(146) 评论(0) 推荐(0)
摘要: Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at... 阅读全文
posted @ 2014-11-29 06:01 LiBlog 阅读(113) 评论(0) 推荐(0)
摘要: You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you cli... 阅读全文
posted @ 2014-11-29 05:54 LiBlog 阅读(123) 评论(0) 推荐(0)
摘要: Given two sorted integer arrays A and B, merge B into A as one sorted array. Note:You may assume that A has enough space (size that is greater or equa... 阅读全文
posted @ 2014-11-29 05:48 LiBlog 阅读(123) 评论(0) 推荐(0)
摘要: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree {3... 阅读全文
posted @ 2014-11-29 05:07 LiBlog 阅读(125) 评论(0) 推荐(0)
摘要: Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le... 阅读全文
posted @ 2014-11-29 04:57 LiBlog 阅读(103) 评论(0) 推荐(0)
摘要: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes... 阅读全文
posted @ 2014-11-29 02:51 LiBlog 阅读(187) 评论(0) 推荐(0)
摘要: Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists: A: ... 阅读全文
posted @ 2014-11-29 02:27 LiBlog 阅读(214) 评论(0) 推荐(0)
摘要: Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2]... 阅读全文
posted @ 2014-11-29 02:17 LiBlog 阅读(135) 评论(0) 推荐(0)
摘要: 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... 阅读全文
posted @ 2014-11-29 02:12 LiBlog 阅读(142) 评论(0) 推荐(0)
摘要: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST'... 阅读全文
posted @ 2014-11-29 01:52 LiBlog 阅读(158) 评论(0) 推荐(0)
摘要: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and ... 阅读全文
posted @ 2014-11-29 01:23 LiBlog 阅读(148) 评论(0) 推荐(0)
摘要: Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.Solution: 1 /**... 阅读全文
posted @ 2014-11-29 01:01 LiBlog 阅读(165) 评论(0) 推荐(0)