
字符串
文章平均质量分 69
Lynn_Baby
这个作者很懒,什么都没留下…
展开
-
LeetCode—longest-valid-parentheses(最长匹配的括号)—java
题目描述:Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest valid parentheses substring is"()", which ha...原创 2018-06-11 17:07:56 · 336 阅读 · 0 评论 -
LeetCode—count-and-say(计数并说出来)—java
题目描述: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"two 1s"or21.21is read off as"one 2, thenone 1"o...原创 2018-06-14 17:30:47 · 526 阅读 · 0 评论 -
LeetCode—generate-parentheses(所有括号的组合)—java
题目描述:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()()"...原创 2018-06-07 20:06:38 · 848 阅读 · 0 评论 -
LeetCode—implement-strstr(找到字符串中的指定子串)—java
题目描述:Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.思路解析:遍历给出的haystack字符串,如果剩下的长度小于needle的长度,返回null如果找到一致的单字符,就循环遍历,直到遍历的...原创 2018-06-08 10:44:01 · 223 阅读 · 0 评论 -
LeetCode—anagrams(返回由相同字母组成的单词)—java
题目描述:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.思路解析:首先判空然后需要创建HashMap来存储排序好的字符串,以及对应有相同字母组成的ArrayList。把每个字符串Arrays.sort以后,再以HashM...原创 2018-06-24 14:00:51 · 1081 阅读 · 0 评论 -
LeetCode—substring-with-concatenation-of-all-words(找给出子串数组组成的所有子串的位置)—java
题目描述: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 concatenation of each word in L exactly once and witho...原创 2018-06-10 17:49:54 · 337 阅读 · 0 评论 -
LeetCode—n-queens(n皇后问题)—java
题目描述:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.Each...原创 2018-06-28 18:05:28 · 1031 阅读 · 0 评论 -
LeetCode—length-of-last-word(最后一个单词的长度)—java
题目描述: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 does not exist, return 0.Note: A word is defin...原创 2018-07-05 23:52:52 · 1126 阅读 · 0 评论 -
LeetCode—simplify-path(简化路径)—java
题目描述: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 cases.Corner Cases:Did you consider the ...原创 2018-07-13 18:42:51 · 898 阅读 · 0 评论 -
LeetCode—valid-parentheses(括号校验)—java
题目描述:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct order,"()"and"()[]{}"are all valid but"(]"and...原创 2018-06-07 17:00:09 · 251 阅读 · 0 评论 -
LeetCode—letter-combinations-of-a-phone-number(手机数字键中字母组合)—java
题目描述:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit string ...原创 2018-06-07 13:32:59 · 654 阅读 · 0 评论 -
LeetCode—multiply-strings(string表示的两个数字相乘)—java
题目描述:Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.思路解析:大数乘法,首先大数是由字符串组成,并且高位在左,低位在右,为了乘起来方...原创 2018-06-21 11:25:05 · 2659 阅读 · 0 评论 -
LeetCode—longest-substring-without-repeating-characters(最长不重复子串)—java
题目描述:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3....原创 2018-06-05 10:35:32 · 189 阅读 · 0 评论 -
LeetCode—zigzag-conversion(之字形字符串)—java
题目描述: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 for better legibility)P A H NA P L S I I...原创 2018-06-05 16:13:05 · 441 阅读 · 0 评论 -
LeetCode—longest-palindromic-substring(最长回文子串)—java
题目描述: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 longest palindromic substring.思路解析:对于查找回文的子串,分为两种:a...原创 2018-06-05 14:32:03 · 195 阅读 · 0 评论 -
LeetCode—string-to-integer-atoi(字符串转换成整数int)—java
题目描述: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 and ask yourself what are the possible input c...原创 2018-06-05 18:06:32 · 541 阅读 · 0 评论 -
LeetCode—regular-expression-matching(正则表达式)—java
题目描述:Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st...原创 2018-06-06 12:33:14 · 305 阅读 · 0 评论 -
LeetCode—integer-to-roman(整数转换成罗马数字)—java
题目描述:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.思路解析:罗马数字的规则:摘自https://www.douban.com/note/335254352/罗马数字共有7个,即I(1)、V(5)、X(10)、L(50)、C(10...原创 2018-06-06 14:14:23 · 339 阅读 · 0 评论 -
LeetCode—roman-to-integer(罗马数字转换成整数)—java
题目描述:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.思路解析:字符串遍历从最高位开始。遇到 'I'、'X' 、'C'的字符时,需要判断是加还是减,区分依据是res是否已经大于5,大于50,大于500其他的字符直接加上对应的数值就可...原创 2018-06-06 15:03:25 · 764 阅读 · 0 评论 -
LeetCode—longest-common-prefix(最长公共前缀)—java
题目描述:Write a function to find the longest common prefix string amongst an array of strings.思路解析:将字符串数组的第一个进行比较,不可能有公共字符串比它还长了然后两层循环,第一层是第一个字符串的长度,0到strs.length()-1第二层是每个字符串的第i个位置,先确定有这个位置,然后判断是否一致。如果没...原创 2018-06-06 16:07:59 · 392 阅读 · 0 评论 -
LeetCode—permutation-sequence(全排列的第k个)—java
题目描述:The set[1,2,3,…,n]contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""312""321&qu原创 2018-07-08 00:05:32 · 809 阅读 · 0 评论