随笔分类 -  leetcode

上一页 1 ··· 9 10 11 12 13 14 15 下一页
摘要:请实现一个函数用来匹配包括'.'和'*'的正则表达式。模式中的字符'.'表示任意一个字符,而'*'表示它前面的字符可以出现任意次(包含0次)。 在本题中,匹配是指字符串的所有字符匹配整个模式。例如,字符串"aaa"与模式"a.a"和"ab*ac*a"匹配,但是与"aa.a"和"ab*a"均不匹配 l 阅读全文
posted @ 2015-09-09 19:24 鸭子船长 阅读(282) 评论(0) 推荐(0)
摘要:输入一棵二叉树,求该树的深度。从根结点到叶结点依次经过的结点(含根、叶结点)形成树的一条路径,最长路径的长度为树的深度。 思路:递归的想法,每次递归,左右子树深度+1,取其中最大值。 1 /* 2 struct TreeNode { 3 int val; 4 struct TreeNode *lef 阅读全文
posted @ 2015-09-01 22:42 鸭子船长 阅读(162) 评论(0) 推荐(0)
摘要:1 /* 2 struct ListNode { 3 int val; 4 struct ListNode *next; 5 ListNode(int x) : 6 val(x), next(NULL) { 7 } 8 };*/ 9 class Solution { 10 public: 11 Li 阅读全文
posted @ 2015-08-26 21:43 鸭子船长 阅读(359) 评论(0) 推荐(0)
摘要:Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The... 阅读全文
posted @ 2015-08-15 23:44 鸭子船长 阅读(260) 评论(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 @ 2015-08-14 17:04 鸭子船长 阅读(162) 评论(0) 推荐(0)
摘要:mplement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below a 阅读全文
posted @ 2015-08-10 00:12 鸭子船长 阅读(212) 评论(0) 推荐(0)
摘要:Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here a 阅读全文
posted @ 2015-08-09 23:25 鸭子船长 阅读(157) 评论(0) 推荐(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 font 阅读全文
posted @ 2015-08-09 15:57 鸭子船长 阅读(160) 评论(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 longes 阅读全文
posted @ 2015-08-09 00:16 鸭子船长 阅读(202) 评论(0) 推荐(0)
摘要:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo 阅读全文
posted @ 2015-08-08 22:36 鸭子船长 阅读(190) 评论(0) 推荐(0)
摘要:Given two words (beginWordandendWord), and a dictionary, find the length of shortest transformation sequence frombeginWordtoendWord, such that:Only on... 阅读全文
posted @ 2015-08-07 22:18 鸭子船长 阅读(181) 评论(0) 推荐(0)
摘要:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next... 阅读全文
posted @ 2015-08-05 21:39 鸭子船长 阅读(149) 评论(0) 推荐(0)
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBA... 阅读全文
posted @ 2015-08-05 15:22 鸭子船长 阅读(486) 评论(0) 推荐(0)
摘要:Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.需考虑3类特殊情况:1、x1=x2,斜率无穷大;2、x1=x2,y1=y2,相同点也要计数,当计算最终结果... 阅读全文
posted @ 2015-07-31 16:52 鸭子船长 阅读(153) 评论(0) 推荐(0)
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,... 阅读全文
posted @ 2015-07-31 15:04 鸭子船长 阅读(122) 评论(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 @ 2015-07-31 14:36 鸭子船长 阅读(164) 评论(0) 推荐(0)
摘要:The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a... 阅读全文
posted @ 2015-07-30 16:37 鸭子船长 阅读(235) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2015-07-29 16:43 鸭子船长 阅读(163) 评论(0) 推荐(0)
摘要:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr... 阅读全文
posted @ 2015-07-29 16:17 鸭子船长 阅读(147) 评论(0) 推荐(0)
摘要:Given an array of integers and an integerk, find out whether there there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the d... 阅读全文
posted @ 2015-07-29 16:13 鸭子船长 阅读(155) 评论(0) 推荐(0)

上一页 1 ··· 9 10 11 12 13 14 15 下一页