摘要: 题目:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains on... 阅读全文
posted @ 2014-08-04 11:22 爱做饭的小莹子 阅读(3268) 评论(0) 推荐(0) 编辑
摘要: 题目:Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-... 阅读全文
posted @ 2014-08-04 11:15 爱做饭的小莹子 阅读(5664) 评论(0) 推荐(0) 编辑
摘要: 题目:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function shou... 阅读全文
posted @ 2014-08-04 10:56 爱做饭的小莹子 阅读(1704) 评论(0) 推荐(0) 编辑
摘要: 题目:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm... 阅读全文
posted @ 2014-08-04 10:30 爱做饭的小莹子 阅读(2876) 评论(1) 推荐(0) 编辑
摘要: 题目:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed f... 阅读全文
posted @ 2014-08-04 09:35 爱做饭的小莹子 阅读(15623) 评论(1) 推荐(3) 编辑
摘要: 题目:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution ... 阅读全文
posted @ 2014-08-04 08:55 爱做饭的小莹子 阅读(2230) 评论(0) 推荐(0) 编辑
摘要: 题目:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".题解:二进制加法都是从最低位(从右加到左)。所以对两个字符串要从最后一位开始加,... 阅读全文
posted @ 2014-08-04 05:07 爱做饭的小莹子 阅读(4922) 评论(2) 推荐(0) 编辑
摘要: 题目:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total ... 阅读全文
posted @ 2014-08-04 03:52 爱做饭的小莹子 阅读(5383) 评论(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 ... 阅读全文
posted @ 2014-08-04 03:22 爱做饭的小莹子 阅读(5734) 评论(0) 推荐(0) 编辑
摘要: 题目:Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes... 阅读全文
posted @ 2014-08-04 02:23 爱做饭的小莹子 阅读(3492) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique lo... 阅读全文
posted @ 2014-08-04 02:08 爱做饭的小莹子 阅读(5496) 评论(0) 推荐(0) 编辑