上一页 1 ··· 5 6 7 8 9 10 11 下一页

2014年3月5日

ZigZag Conversion

摘要: 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 font for better legibility)P A H NA P L S I I GY I RAnd then read line by line:"PAHNAPLSIIGYIR"Write the code that will take a string and 阅读全文

posted @ 2014-03-05 22:11 pengyu2003 阅读(130) 评论(0) 推荐(0)

Longest Substring Without Repeating Characters

摘要: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.这 阅读全文

posted @ 2014-03-05 21:22 pengyu2003 阅读(115) 评论(0) 推荐(0)

Add Two Numbers

摘要: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.Input:(2 -> 4 -> 3) + (5 -> 6 -> 4)Output:7 -> 0 -> 8简单链表题/** * Definition 阅读全文

posted @ 2014-03-05 10:36 pengyu2003 阅读(158) 评论(0) 推荐(0)

2014年3月4日

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-to-leaf path1->2->3which represents the number123.Find the total sum of all root-to-leaf numbers.For example, 1 / \ 2 3The root-to-leaf path1->2represents the number12.T 阅读全文

posted @ 2014-03-04 15:35 pengyu2003 阅读(122) 评论(0) 推荐(0)

Valid Palindromed

摘要: iven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama"is a palindrome."race a car"isnota palindrome.Note:Have you consider that the string might be empty? This is a good question to 阅读全文

posted @ 2014-03-04 15:20 pengyu2003 阅读(139) 评论(0) 推荐(0)

Best Time to Buy and Sell Stock

摘要: Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.vector下标,初始化class Solution {public: int maxProfit(vector... 阅读全文

posted @ 2014-03-04 14:58 pengyu2003 阅读(154) 评论(0) 推荐(0)

2014年3月3日

3-3

摘要: 每天就是简单刷刷题,书看的很少。刷水题分明纯乎就是在逃避现实,还是老老实实拿起书看吧。自己简历都没什么内容可以写,是时候清醒清醒了。牛人总是不受外物影响,无论别人谈论诱惑多大的话题,他该看书还是看书,该做题还是做题,最多戴上耳机隔离。好像刷题逃避现实啊…… 阅读全文

posted @ 2014-03-03 20:51 pengyu2003 阅读(128) 评论(0) 推荐(0)

Pascal's Triangle II

摘要: Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(k) extra space?下标标错了,改一次通过,总体上是水题,不过也许有空间使用更少的算法。class Solution {public: vector getRow(int rowIndex) { vector vec; vec.push_back(1); ... 阅读全文

posted @ 2014-03-03 20:27 pengyu2003 阅读(73) 评论(0) 推荐(0)

Pascal's Triangle

摘要: 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]]模拟由金子塔型换成下三角型会看的清楚一些,注意numRows = 1,2的特殊情况。总体来说简单。class Solution {public: vector > generate(int numRows) { vector > re; for(i... 阅读全文

posted @ 2014-03-03 17:13 pengyu2003 阅读(79) 评论(0) 推荐(0)

Path Sum II

摘要: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1return[ [5,4,11,2]... 阅读全文

posted @ 2014-03-03 16:24 pengyu2003 阅读(96) 评论(0) 推荐(0)

上一页 1 ··· 5 6 7 8 9 10 11 下一页

导航