摘要: Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp... 阅读全文
posted @ 2014-07-11 13:35 Hicandyman 阅读(144) 评论(0) 推荐(0)
摘要: Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be on... 阅读全文
posted @ 2014-07-10 14:35 Hicandyman 阅读(101) 评论(0) 推荐(0)
摘要: Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Fo... 阅读全文
posted @ 2014-07-10 09:11 Hicandyman 阅读(89) 评论(0) 推荐(0)
摘要: Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100"class Solution {public: string addBinary(stri... 阅读全文
posted @ 2014-07-09 13:43 Hicandyman 阅读(90) 评论(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.思路:递归。主要是注意调用时起... 阅读全文
posted @ 2014-07-09 13:27 Hicandyman 阅读(104) 评论(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-nega... 阅读全文
posted @ 2014-07-09 03:49 Hicandyman 阅读(147) 评论(0) 推荐(0)
摘要: GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]... 阅读全文
posted @ 2014-07-09 02:09 Hicandyman 阅读(155) 评论(0) 推荐(0)
摘要: Write a function to find the longest common prefix string amongst an array of strings.方法一: 1 class Solution { 2 public: 3 string longestCommonPref... 阅读全文
posted @ 2014-07-08 14:38 Hicandyman 阅读(120) 评论(0) 推荐(0)
摘要: Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exampl... 阅读全文
posted @ 2014-07-08 14:14 Hicandyman 阅读(128) 评论(0) 推荐(0)
摘要: Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a... 阅读全文
posted @ 2014-07-07 14:43 Hicandyman 阅读(97) 评论(0) 推荐(0)