随笔分类 -  Leetcode+题

摘要:Say you have an array for which the i th element is the price of a given stock on day i. If you were only permitted to complete at most one transactio 阅读全文
posted @ 2017-06-29 16:05 王大咩的图书馆 阅读(219) 评论(0) 推荐(0)
摘要:Given a 2D board containing'X'and'O', capture all regions surrounded by'X'. A region is captured by flipping all'O's into'X's in that surrounded regio 阅读全文
posted @ 2017-06-29 15:00 王大咩的图书馆 阅读(209) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given[100, 4, 200, 1, 3, 2],The longest 阅读全文
posted @ 2017-06-28 16:52 王大咩的图书馆 阅读(572) 评论(0) 推荐(0)
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For exampl 阅读全文
posted @ 2017-06-28 00:55 王大咩的图书馆 阅读(501) 评论(1) 推荐(0)
摘要:Given two binary strings, return their sum (also a binary string). For example,a ="11"b ="1"Return"100". 题意:将两个以字符串形式保存的二进制数进行相加。 思路:其实不管是以数组、字符串形式,加或 阅读全文
posted @ 2017-06-27 17:56 王大咩的图书馆 阅读(486) 评论(0) 推荐(1)
摘要:Validate if a given string is numeric. Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>true Note: It is intended for the problem s 阅读全文
posted @ 2017-06-27 16:51 王大咩的图书馆 阅读(274) 评论(0) 推荐(0)
摘要:Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You shou 阅读全文
posted @ 2017-06-27 15:03 王大咩的图书馆 阅读(199) 评论(0) 推荐(0)
摘要:Given an absolute path for a file (Unix-style), simplify it. For example,path ="/home/", =>"/home"path ="/a/./b/../../c/", =>"/c" click to show corner 阅读全文
posted @ 2017-06-27 00:43 王大咩的图书馆 阅读(340) 评论(0) 推荐(0)
摘要:Implement wildcard pattern matching with support for'?'and'*'. 这题和正则表达式匹配有点类似,' . '和本题中的' ? '一样,区别在于' * ',在正则表达式那题中,' * '可以表示之前字符的0个或多个;本题中,可以表示任意字符串。 阅读全文
posted @ 2017-06-26 13:12 王大咩的图书馆 阅读(338) 评论(0) 推荐(1)
摘要:Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. 题意:anagrams的意思是回文构词法。回文构词法有一个特点:单词里 阅读全文
posted @ 2017-06-25 21:54 王大咩的图书馆 阅读(356) 评论(0) 推荐(0)
摘要:Given a string s consists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string. If the last word 阅读全文
posted @ 2017-06-25 16:50 王大咩的图书馆 阅读(217) 评论(0) 推荐(0)
摘要:Implement 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 阅读全文
posted @ 2017-06-25 16:32 王大咩的图书馆 阅读(608) 评论(0) 推荐(0)
摘要:Implement regular expression matching with support for'.'and'*'. 题意:' . '能匹配任意字符,‘ * ‘表示之前的那个字符可以是0个、1个或者多个,(注意:s= ba和 p= a*bc也是匹配的,*表示p中 * 之前的字符为0个,但 阅读全文
posted @ 2017-06-25 11:56 王大咩的图书馆 阅读(337) 评论(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 @ 2017-06-25 02:26 王大咩的图书馆 阅读(2143) 评论(2) 推荐(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 @ 2017-06-23 22:31 王大咩的图书馆 阅读(2973) 评论(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 fo 阅读全文
posted @ 2017-06-23 16:45 王大咩的图书馆 阅读(225) 评论(0) 推荐(0)
摘要:You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatena 阅读全文
posted @ 2017-06-22 17:24 王大咩的图书馆 阅读(398) 评论(0) 推荐(0)
摘要:Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack. 题意:判断一个字符是否在另一个中,若是,则返 阅读全文
posted @ 2017-06-21 19:47 王大咩的图书馆 阅读(373) 评论(0) 推荐(1)
摘要:Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-neg 阅读全文
posted @ 2017-06-20 17:33 王大咩的图书馆 阅读(679) 评论(0) 推荐(0)
摘要:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1is read off as"one 1"or11.11is read off as"t 阅读全文
posted @ 2017-06-20 16:31 王大咩的图书馆 阅读(373) 评论(0) 推荐(0)