字符串
文章平均质量分 72
jmspan
这个作者很懒,什么都没留下…
展开
-
LeetCode 249. Group Shifted Strings
原题网址:https://leetcode.com/problems/group-shifted-strings/Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which f原创 2016-04-07 12:53:53 · 759 阅读 · 0 评论 -
LeetCode 12. Integer to Roman(阿拉伯转罗马数字)
原题网址:https://leetcode.com/problems/integer-to-roman/Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.方法:理解罗马数字的规律。二分法。public clas原创 2016-05-19 05:27:37 · 470 阅读 · 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.方法一:暴力求解。public class Solution { public Strin原创 2016-05-19 05:51:55 · 705 阅读 · 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原创 2016-05-20 10:46:06 · 569 阅读 · 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".方法一:使用字符串来表示。public class So原创 2016-05-22 00:04:55 · 583 阅读 · 0 评论 -
LeetCode 79. Word Search(单词查找)
原题网址:https://leetcode.com/problems/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原创 2016-05-22 05:21:03 · 1173 阅读 · 0 评论 -
LeetCode 97. Interleaving String(字符串交织)
原题网址:https://leetcode.com/problems/interleaving-string/Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When原创 2016-05-23 00:39:00 · 956 阅读 · 0 评论 -
LeetCode 291. Word Pattern II(单词模式II)
原题网址:https://leetcode.com/problems/word-pattern-ii/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 bet原创 2016-04-16 04:00:07 · 1214 阅读 · 0 评论 -
HackRank Two Two
原题网址:https://www.hackerrank.com/challenges/two-twoProf. Twotwo as the name suggests is very fond powers of 2. Moreover he also has special affinity to number 800. He is known for carrying quirky e原创 2016-07-11 04:36:29 · 1082 阅读 · 0 评论 -
LeetCode 340. Longest Substring with At Most K Distinct Characters(最长字串)
原题网址:https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/Given a string, find the length of the longest substring T that contains at most k distinct characters.原创 2016-04-30 09:10:31 · 1307 阅读 · 0 评论 -
LeetCode 161. One Edit Distance(编辑距离)
原题网址:https://leetcode.com/problems/one-edit-distance/Given two strings S and T, determine if they are both one edit distance apart.方法:两个字符串长度最多相差1,或者最多只有一个字符不同。public class Solution { publ原创 2016-05-25 01:40:56 · 1133 阅读 · 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.方法:KMP算法。p原创 2016-05-20 10:35:48 · 837 阅读 · 0 评论 -
LeetCode 72. Edit Distance(编辑距离)
原题网址:https://leetcode.com/problems/edit-distance/Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)Y原创 2016-05-22 05:18:34 · 679 阅读 · 0 评论 -
LeetCode 58. Length of Last Word(最后一个单词的长度)
原题网址:https://leetcode.com/problems/length-of-last-word/Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.原创 2016-05-21 07:44:17 · 505 阅读 · 0 评论 -
LeetCode 5. Longest Palindromic Substring(最长回文子串)
原题网址:https://leetcode.com/problems/longest-palindromic-substring/Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there e原创 2016-05-19 03:25:31 · 501 阅读 · 0 评论 -
LeetCode 246. Strobogrammatic Number
原题网址:https://leetcode.com/problems/strobogrammatic-number/A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).Write a function to determ原创 2016-04-07 06:08:22 · 1092 阅读 · 0 评论 -
LeetCode 266. Palindrome Permutation(对称排列)
原题网址:https://leetcode.com/problems/palindrome-permutation/Given a string, determine if a permutation of the string could form a palindrome.For example,"code" -> False, "aab" -> True, "ca原创 2016-04-11 00:02:33 · 890 阅读 · 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 stri原创 2016-05-25 01:36:04 · 1771 阅读 · 0 评论 -
LeetCode 179. Largest Number(最大数)
原题网址:https://leetcode.com/problems/largest-number/Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest原创 2016-05-25 01:36:20 · 1904 阅读 · 0 评论 -
LeetCode 299. Bulls and Cows(公牛和母牛)
原题网址:https://leetcode.com/problems/bulls-and-cows/You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. E原创 2016-04-17 00:36:08 · 413 阅读 · 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".方法:循环。public c原创 2016-04-30 12:04:53 · 835 阅读 · 0 评论 -
LeetCode 288. Unique Word Abbreviation(单词缩写)
原题网址:https://leetcode.com/problems/unique-word-abbreviation/An abbreviation of a word follows the form . Below are some examples of word abbreviations:a) it --> it (no原创 2016-04-15 14:19:44 · 966 阅读 · 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.Examples:Given "ab原创 2016-05-01 07:12:41 · 469 阅读 · 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-05-26 00:54:39 · 587 阅读 · 0 评论 -
LeetCode 151. Reverse Words in a String(反转单词)
原题网址:https://leetcode.com/problems/reverse-words-in-a-string/Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".U原创 2016-05-26 01:06:09 · 560 阅读 · 0 评论 -
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.原创 2016-05-27 00:22:29 · 828 阅读 · 0 评论 -
LeetCode 131. Palindrome Partitioning(回文分区)
原题网址:https://leetcode.com/problems/palindrome-partitioning/Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitionin原创 2016-05-27 00:25:24 · 663 阅读 · 0 评论 -
LeetCode 318. Maximum Product of Word Lengths(最大单词长度乘积)
原题网址:https://leetcode.com/problems/maximum-product-of-word-lengths/Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share comm原创 2016-04-23 13:28:40 · 897 阅读 · 1 评论 -
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 "hol原创 2016-04-30 12:16:13 · 836 阅读 · 0 评论 -
LeetCode 434. Number of Segments in a String
原题网址:https://leetcode.com/problems/number-of-segments-in-a-string/Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.Ple原创 2016-12-20 03:42:35 · 623 阅读 · 0 评论