随笔分类 -  Leetcode

上一页 1 2 3 4 5 6 7 下一页

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

posted @ 2014-12-09 13:35 Ryan-Xing 阅读(89) 评论(0) 推荐(0)

Leetcode: Longest Common Prefix
摘要:Write a function to find the longest common prefix string amongst an array of strings.分析:这道题没什么好方法,暴力搜索比较即可,在用C++实现时有一个小trick就是"Ifposis equal to thest... 阅读全文

posted @ 2014-12-09 12:47 Ryan-Xing 阅读(91) 评论(0) 推荐(0)

Leetcode: Longest Palindromic Substring
摘要:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa... 阅读全文

posted @ 2014-12-09 12:07 Ryan-Xing 阅读(184) 评论(0) 推荐(0)

Leetcode: 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 fo... 阅读全文

posted @ 2014-12-08 19:39 Ryan-Xing 阅读(132) 评论(0) 推荐(0)

Leetcode: Binary Tree Maximum Path Sum
摘要:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ... 阅读全文

posted @ 2014-12-08 12:46 Ryan-Xing 阅读(176) 评论(0) 推荐(0)

Leetcode: Edit Distance
摘要:Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the fol... 阅读全文

posted @ 2014-12-07 16:18 Ryan-Xing 阅读(131) 评论(0) 推荐(0)

Leetcode: Sort Colors
摘要:Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文

posted @ 2014-12-07 15:36 Ryan-Xing 阅读(165) 评论(0) 推荐(0)

Leetcode: Word Search
摘要:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjace... 阅读全文

posted @ 2014-12-07 00:47 Ryan-Xing 阅读(116) 评论(0) 推荐(0)

Leetcode: Intersection of Two Linked Lists
摘要: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: a... 阅读全文

posted @ 2014-12-06 20:22 Ryan-Xing 阅读(146) 评论(0) 推荐(0)

Leetcode: Generate Parentheses
摘要:Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))... 阅读全文

posted @ 2014-12-05 21:16 Ryan-Xing 阅读(186) 评论(0) 推荐(0)

Leetcode: Maximum Depth of Binary Tree
摘要: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-12-05 19:55 Ryan-Xing 阅读(114) 评论(0) 推荐(0)

Leetcode: 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(... 阅读全文

posted @ 2014-12-05 17:07 Ryan-Xing 阅读(145) 评论(0) 推荐(0)

Leetcode: strStr()
摘要:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.分析:该题是经典的串匹配,我们可以用KMP来解,时间... 阅读全文

posted @ 2014-12-05 15:40 Ryan-Xing 阅读(213) 评论(0) 推荐(0)

Leetcode: Binary Tree Postorder Traversal
摘要:Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No... 阅读全文

posted @ 2014-12-04 20:51 Ryan-Xing 阅读(131) 评论(0) 推荐(0)

Leetcode: Binary Tree Preorder Traversal
摘要:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Not... 阅读全文

posted @ 2014-12-04 20:20 Ryan-Xing 阅读(200) 评论(0) 推荐(0)

Leetcode: Binary Tree Inorder Traversal
摘要:Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note... 阅读全文

posted @ 2014-12-04 20:07 Ryan-Xing 阅读(214) 评论(0) 推荐(0)

Leetcode: Longest Valid Parentheses
摘要:Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest... 阅读全文

posted @ 2014-12-04 19:15 Ryan-Xing 阅读(175) 评论(0) 推荐(0)

Leetcode: Multiply Strings
摘要: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-12-04 15:01 Ryan-Xing 阅读(126) 评论(0) 推荐(0)

Leetcode: Climbing Stairs
摘要:You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文

posted @ 2014-12-03 23:59 Ryan-Xing 阅读(111) 评论(0) 推荐(0)

Leetcode: Regular Expression Matching
摘要:Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The... 阅读全文

posted @ 2014-12-03 22:14 Ryan-Xing 阅读(157) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 下一页