string
文章平均质量分 63
小榕流光
这个作者很懒,什么都没留下…
展开
-
[leetcode] 139. Word Break 解题报告
题目链接:https://leetcode.com/problems/word-break/Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.原创 2015-10-31 13:54:22 · 1214 阅读 · 0 评论 -
[leetcode] 392. Is Subsequence 解题报告
题目链接:https://leetcode.com/problems/is-subsequence/Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t原创 2016-09-09 14:49:15 · 2446 阅读 · 0 评论 -
[leetcode] 214. Shortest Palindrome 解题报告
题目链接:https://leetcode.com/problems/shortest-palindrome/Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrom原创 2016-06-12 04:21:16 · 4544 阅读 · 1 评论 -
[leetcode] 282. Expression Add Operators 解题报告
题目链接:https://leetcode.com/problems/expression-add-operators/Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -,原创 2016-05-16 05:47:24 · 3168 阅读 · 0 评论 -
[leetcode] 224. Basic Calculator 解题报告
题目链接: https://leetcode.com/problems/basic-calculator/Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ),原创 2016-05-04 16:59:18 · 1072 阅读 · 0 评论 -
[leetcode] 227. Basic Calculator II 解题报告
题目链接: https://leetcode.com/problems/basic-calculator-ii/Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *原创 2016-05-02 15:14:05 · 1074 阅读 · 0 评论 -
[leetcode] 157. Read N Characters Given Read4 解题报告
题目链接:https://leetcode.com/problems/read-n-characters-given-read4/The API: int read4(char *buf) reads 4 characters at a time from a file.The return value is the actual number of characters re原创 2016-03-09 05:10:39 · 3055 阅读 · 0 评论 -
[leetcode] 158. Read N Characters Given Read4 II - Call multiple times 解题报告
题目链接:https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times/The API: int read4(char *buf) reads 4 characters at a time from a file.The return value is the actual原创 2016-03-20 07:32:08 · 1111 阅读 · 0 评论 -
[leetcode] 3. Longest Substring Without Repeating Characters 解题报告
题目链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/Given a string, find the length of the longest substring without repeating characters. For example, the longest原创 2015-12-17 15:34:07 · 372 阅读 · 0 评论 -
[leetcode] 93. Restore IP Addresses 解题报告
题目链接: https://leetcode.com/problems/restore-ip-addresses/Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "255255原创 2016-05-07 23:22:04 · 1708 阅读 · 0 评论 -
[leetcode] 43. Multiply Strings 解题报告
题目链接:https://leetcode.com/problems/multiply-strings/Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and原创 2016-02-21 15:03:17 · 558 阅读 · 0 评论 -
[leetcode] 271. Encode and Decode Strings 解题报告
题目链接: https://leetcode.com/problems/encode-and-decode-strings/Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to原创 2016-03-17 12:09:11 · 3149 阅读 · 0 评论 -
[leetcode] 247. Strobogrammatic Number II 解题报告
题目链接: https://leetcode.com/problems/strobogrammatic-number-ii/A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).Find all strobogrammat原创 2016-03-21 14:38:52 · 3550 阅读 · 0 评论 -
[leetcode] 267. Palindrome Permutation II 解题报告
题目链接: https://leetcode.com/problems/palindrome-permutation-ii/Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permu原创 2016-03-14 15:41:05 · 1642 阅读 · 0 评论 -
[leetcode] 159. Longest Substring with At Most Two Distinct Characters 解题报告
题目链接:https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters/Given a string, find the length of the longest substring T that contains at most 2 distinct characters.原创 2016-03-18 13:38:51 · 865 阅读 · 0 评论 -
[leetcode] 243. Shortest Word Distance 解题报告
题目链接:https://leetcode.com/problems/shortest-word-distance/Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.For example,As原创 2016-03-11 15:03:54 · 1618 阅读 · 0 评论 -
[leetcode] 171. Excel Sheet Column Number 解题报告
题目链接:https://leetcode.com/problems/excel-sheet-column-number/Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column num原创 2015-12-27 15:52:30 · 452 阅读 · 0 评论 -
[leetcode] 451. Sort Characters By Frequency 解题报告
题目链接:https://leetcode.com/problems/sort-characters-by-frequency/Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input:"tree"Output:"eert"Ex原创 2016-11-11 05:40:30 · 4284 阅读 · 0 评论 -
[leetcode] 290. Word Pattern 解题报告
题目链接:https://leetcode.com/problems/word-pattern/Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection betwee原创 2015-12-27 07:05:32 · 767 阅读 · 0 评论 -
[leetcode] 438. Find All Anagrams in a String 解题报告
题目链接:https://leetcode.com/problems/find-all-anagrams-in-a-string/Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.Strings consists of lowercase Engl原创 2016-10-26 22:46:39 · 3558 阅读 · 0 评论 -
[leetcode] 71. Simplify Path 解题报告
题目链接: https://leetcode.com/problems/simplify-path/Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"原创 2016-05-09 06:53:47 · 613 阅读 · 0 评论 -
[leetcode] 28. Implement strStr() 解题报告
题目链接:https://leetcode.com/problems/implement-strstr/Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.思路:很简单的一题,原创 2015-12-28 16:32:40 · 1132 阅读 · 0 评论 -
[leetcode] 14. Longest Common Prefix 解题报告
题目链接:https://leetcode.com/problems/longest-common-prefix/Write a function to find the longest common prefix string amongst an array of strings.思路:每次子串长度加1,直到子串不相等即是最大公共前缀代码如下:class Solut原创 2015-12-23 00:34:33 · 462 阅读 · 0 评论 -
[leetcode] 10. Regular Expression Matching 解题报告
题目链接: https://leetcode.com/problems/regular-expression-matching/Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of原创 2016-05-18 17:07:49 · 953 阅读 · 0 评论 -
[leetcode] 408. Valid Word Abbreviation 解题报告
题目链接:https://leetcode.com/problems/valid-word-abbreviation/Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation.A string such原创 2016-10-10 03:48:20 · 3164 阅读 · 0 评论 -
[leetcode] 269. Alien Dictionary 解题报告
题目链接: https://leetcode.com/problems/alien-dictionary/There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of words原创 2016-03-25 15:58:39 · 6934 阅读 · 1 评论 -
[leetcode] 394. Decode String 解题报告
题目链接: https://leetcode.com/problems/decode-string/Given an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square br原创 2016-09-05 12:19:56 · 4632 阅读 · 0 评论 -
[leetcode] 387. First Unique Character in a String 解题报告
题目链接:https://leetcode.com/problems/first-unique-character-in-a-string/Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examp原创 2016-08-25 02:09:38 · 2617 阅读 · 0 评论 -
[leetcode] 140. Word Break II 解题报告
题目链接:https://leetcode.com/problems/word-break-ii/Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return al原创 2015-11-04 12:01:41 · 1296 阅读 · 0 评论 -
[leetcode] 388. Longest Absolute File Path 解题报告
题目链接: https://leetcode.com/problems/longest-absolute-file-path/Suppose we abstract our file system by a string in the following manner:The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" re原创 2016-08-24 08:53:58 · 6696 阅读 · 0 评论 -
[leetcode] 186. Reverse Words in a String II 解题报告
题目链接: https://leetcode.com/problems/reverse-words-in-a-string-ii/Given an input string, reverse the string word by word. A word is defined as a sequence of non-space characters.The input str原创 2016-03-14 15:06:57 · 1516 阅读 · 0 评论 -
[leetcode] 245. Shortest Word Distance III 解题报告
题目链接: https://leetcode.com/problems/shortest-word-distance-iii/This is a follow up of Shortest Word Distance. The only difference is now word1 could be the same asword2.Given a list of wor原创 2016-03-13 05:52:36 · 1820 阅读 · 0 评论 -
[leetcode] 241. Different Ways to Add Parentheses 解题报告
题目链接: https://leetcode.com/problems/different-ways-to-add-parentheses/Given a string of numbers and operators, return all possible results from computing all the different possible ways to group原创 2016-05-01 14:08:59 · 618 阅读 · 0 评论 -
[leetcode] 125. Valid Palindrome 解题报告
题目链接:https://leetcode.com/problems/valid-palindrome/Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan,原创 2015-12-19 05:40:59 · 523 阅读 · 0 评论 -
[leetcode] 67. Add Binary 解题报告
题目链接:https://leetcode.com/problems/add-binary/Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".思路:刚开始的思路反转字符串,然后再进行运算,不过代码太原创 2015-12-27 17:15:30 · 624 阅读 · 0 评论 -
[leetcode] 13. Roman to Integer 解题报告
题目链接:https://leetcode.com/problems/roman-to-integer/Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.思路:罗马数字总共有七个 即I(1)、V(5)、X(1原创 2015-12-29 14:08:01 · 550 阅读 · 0 评论 -
[leetcode] 8. String to Integer (atoi) 解题报告
题目链接:https://leetcode.com/problems/string-to-integer-atoi/Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please原创 2015-12-29 17:19:22 · 535 阅读 · 0 评论 -
[leetcode] 65. Valid Number 解题报告
题目链接:https://leetcode.com/problems/valid-number/Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote:原创 2016-05-14 11:59:38 · 1299 阅读 · 0 评论 -
[leetcode] 344. Reverse String 解题报告
题目链接:https://leetcode.com/problems/reverse-string/Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".思路: 很简单的一题, 没什么好原创 2016-04-29 02:01:16 · 605 阅读 · 0 评论 -
[leetcode] 345. Reverse Vowels of a String 解题报告
题目链接: https://leetcode.com/problems/reverse-vowels-of-a-string/Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "ho原创 2016-04-29 01:57:59 · 1121 阅读 · 0 评论