![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
字符串处理
xiaocong1990
这个作者很懒,什么都没留下…
展开
-
[lintcode]386. 最多有k个不同字符的最长子字符串
题目链接:http://www.lintcode.com/zh-cn/problem/longest-substring-with-at-most-k-distinct-characters/给定一个字符串,找到最多有k个不同字符的最长子字符串。您在真实的面试中是否遇到过这个题?Yes样例例如,给定 s ="eceba",原创 2018-04-18 10:53:29 · 666 阅读 · 0 评论 -
[leetcode]first-unique-character-in-a-string 字符串中的第一个唯一字符
【代码】[leetcode]first-unique-character-in-a-string 字符串中的第一个唯一字符。原创 2024-06-27 10:08:11 · 164 阅读 · 0 评论 -
[leetcode]5. Longest Palindromic Substring 最长回文子串
题目链接:https://leetcode.com/problems/longest-palindromic-substring/#/descriptionGiven a strings, find the longest palindromic substring ins. You may assume that the maximum length ofsis 1000.原创 2017-04-23 14:01:25 · 240 阅读 · 1 评论 -
[LeetCode] 159. Longest Substring with At Most Two Distinct Characters 最多有两个不同字符的最长子串
【代码】[LeetCode] 159. Longest Substring with At Most Two Distinct Characters 最多有两个不同字符的最长子串。原创 2024-06-04 16:22:06 · 336 阅读 · 0 评论 -
[leetcode]340. Longest Substring with At Most K Distinct Characters 最多有K个不同字符的最长子串
的拓展,而且那道题中的解法一和解法二直接将2换成k就行了。原创 2024-06-04 16:21:11 · 238 阅读 · 0 评论 -
[leetcode]424. Longest Repeating Character Replacement
题目链接:https://leetcode.com/problems/longest-repeating-character-replacement/Given a string that consists of only uppercase English letters, you can replace any letter in the string with another l原创 2017-01-24 23:51:36 · 235 阅读 · 1 评论 -
【leetcode】最长公共子序列
链接:力扣给定两个字符串text1 和text2,返回这两个字符串的最长 公共子序列 的长度。如果不存在 公共子序列 ,返回 0 。一个字符串的子序列是指这样一个新的字符串:它是由原字符串在不改变字符的相对顺序的情况下删除某些字符(也可以不删除任何字符)后组成的新字符串。例如,"ace" 是 "abcde" 的子序列,但 "aec" 不是 "abcde" 的子序列。两个字符串的 公共子序列 是这两个字符串所共同拥有的子序列。示例 1:输入:text1 = "abcde...原创 2022-01-10 22:00:36 · 133 阅读 · 0 评论 -
[leetcode] 最小覆盖子串
没错,其实在 sss 中,有的字符我们是不关心的,我们只关心 ttt 中出现的字符,我们可不可以先预处理 sss,扔掉那些 ttt 中没有出现的字符,然后再做滑动窗口呢?当窗口包含 ttt 全部所需的字符后,如果能收缩,我们就收缩窗口直到得到最小窗口。我们可以用一个哈希表表示 ttt 中所有的字符以及它们的个数,用一个哈希表动态维护窗口中所有的字符以及它们的个数,如果这个动态表中包含 ttt 的哈希表中的所有字符,并且对应的个数都不小于 ttt 的哈希表中各个字符的个数,那么当前的窗口是「可行」的。原创 2024-05-02 09:44:49 · 19 阅读 · 0 评论 -
[leetcode]647. Palindromic Substrings
题目链接:https://leetcode.com/problems/palindromic-substrings/#/descriptionGiven a string, your task is to count how many palindromic substrings in this string.The substrings with different star原创 2017-07-25 21:38:15 · 1228 阅读 · 1 评论 -
[leetcode]44. Wildcard Matching
链接:https://leetcode.com/problems/wildcard-matching/description/ Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'.'?' Matches any sin...原创 2018-05-13 18:08:28 · 304 阅读 · 0 评论 -
[lintcode]29. 交叉字符串
链接:http://www.lintcode.com/zh-cn/problem/interleaving-string/ 给出三个字符串:s1、s2、s3,判断s3是否由s1和s2交叉构成。 您在真实的面试中是否遇到过这个题? Yes样例比如 s1 = "aabcc" s2 = "dbbca" - 当 s3 = "aadbbcbcac",返回 tru...原创 2018-03-19 16:40:31 · 300 阅读 · 0 评论 -
[leetcode]87. Scramble String
题目链接:https://leetcode.com/problems/scramble-string/description/ Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one...原创 2017-08-28 21:43:35 · 383 阅读 · 0 评论 -
[leetcode]664. Strange Printer
题目链接:https://leetcode.com/problems/strange-printer/description/ There is a strange printer with the following two special requirements:The printer can only print a sequence of the same character...原创 2017-09-09 17:22:48 · 933 阅读 · 0 评论 -
[leetcode]115. Distinct Subsequences
题目链接:https://leetcode.com/problems/distinct-subsequences/description/ Given a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is ...原创 2017-08-15 12:54:18 · 238 阅读 · 0 评论 -
[lintcode]889. Sentence Screen Fitting
链接:http://www.lintcode.com/zh-cn/problem/sentence-screen-fitting/ Given a rows x cols screen and a sentence represented by a list of non-empty words, find how many times the given sentence can ...原创 2018-03-24 18:55:00 · 350 阅读 · 0 评论 -
[leetcode]467. Unique Substrings in Wraparound String
题目链接:https://leetcode.com/problems/unique-substrings-in-wraparound-string/#/description Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look l...原创 2017-07-26 11:50:56 · 250 阅读 · 0 评论 -
[leetcode]93. Restore IP Addresses
题目链接:https://leetcode.com/problems/restore-ip-addresses/tabs/description Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Gi...原创 2017-07-28 12:13:52 · 190 阅读 · 0 评论 -
[腾讯]编码
假定一种编码的编码范围是a ~ y的25个字母,从1位到4位的编码,如果我们把该编码按字典序排序,形成一个数组如下: a, aa, aaa, aaaa, aaab, aaac, … …, b, ba, baa, baaa, baab, baac … …, yyyw, yyyx, yyyy 其中a的Index为0,aa的Index为1,aaa的Index为2,以此类推。 编写一个函数,输入是任意一个...原创 2018-09-14 22:27:47 · 360 阅读 · 0 评论 -
[leetcode]516. Longest Palindromic Subsequence 最长回文子序列
题目链接:https://leetcode.com/problems/longest-palindromic-subsequence/Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000....原创 2017-02-10 23:43:35 · 2120 阅读 · 1 评论 -
[leetcode]583. Delete Operation for Two Strings
题目链接:https://leetcode.com/problems/delete-operation-for-two-strings/#/description Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where...原创 2017-06-10 17:03:58 · 228 阅读 · 0 评论 -
[leetcode]438. Find All Anagrams in a String 找到字符串中所有字母异位词
链接:https://leetcode.com/problems/find-all-anagrams-in-a-string/description/Given a stringsand anon-emptystringp, find all the start indices ofp's anagrams ins.Strings consists of lowercase ...原创 2018-09-01 15:25:32 · 106 阅读 · 1 评论 -
[leetcode]242. Valid Anagram
链接:https://leetcode.com/problems/valid-anagram/description/Given two strings s and t , write a function to determine if t is an anagram of s.Example 1:Input: s = "anagram", t = "nagaram"Output...原创 2018-09-01 15:29:37 · 97 阅读 · 0 评论 -
[leetcode]839. Similar String Groups
链接:https://leetcode.com/problems/similar-string-groups/description/ Two strings X and Y are similar if we can swap two letters (in different positions) of X, so that it equals Y.For example, "ta...原创 2018-06-07 21:57:26 · 922 阅读 · 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, a ca...原创 2016-11-30 20:02:04 · 222 阅读 · 0 评论 -
[leetcode]151. Reverse Words in a String
链接:https://leetcode.com/problems/reverse-words-in-a-string/description/ Given an input string, reverse the string word by word.Example: Input: "the sky is blue",Output: "blue is sky the"....原创 2018-09-01 18:09:48 · 148 阅读 · 0 评论 -
[leetcode]557. Reverse Words in a String III
链接:https://leetcode.com/problems/reverse-words-in-a-string-iii/description/Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespac...原创 2018-09-01 18:16:10 · 95 阅读 · 0 评论 -
[leetcode]3. Longest Substring Without Repeating Characters. 无重复字符的最长子串
题目链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/#/descriptionGiven a string, find the length of thelongest substringwithout repeating characters.Examples:G...原创 2017-05-29 10:58:39 · 266 阅读 · 1 评论 -
[leetcode]395. Longest Substring with At Least K Repeating Characters
题目链接:https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/#/description Find the length of the longest substring T of a given string (consists of lowercase letters ...原创 2017-05-07 17:30:07 · 235 阅读 · 0 评论 -
[leetcode]443. String Compression
链接:https://leetcode.com/problems/string-compression/description/Given an array of characters, compress it in-place.The length after compression must always be smaller than or equal to the original...原创 2018-09-02 16:58:40 · 105 阅读 · 0 评论 -
[leetcode]208. Implement Trie (Prefix Tree)
题目链接:https://leetcode.com/problems/implement-trie-prefix-tree/tabs/description Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lo...原创 2017-07-28 20:52:55 · 213 阅读 · 0 评论 -
[leetcode]211. Add and Search Word - Data structure design
题目链接:https://leetcode.com/problems/add-and-search-word-data-structure-design/tabs/description Design a data structure that supports the following two operations:void addWord(word)bool search(w...原创 2017-07-28 21:49:55 · 362 阅读 · 0 评论 -
[leetcode]79. Word Search
题目链接:https://leetcode.com/problems/word-search/#/descriptionGiven a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent ce...原创 2017-05-14 16:12:21 · 432 阅读 · 1 评论 -
[leetcode]212. Word Search II
链接:https://leetcode.com/problems/word-search-ii/description/Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters o...原创 2018-05-30 19:55:36 · 212 阅读 · 1 评论 -
[leetcode]214. Shortest Palindrome
链接:https://leetcode.com/problems/shortest-palindrome/description/ 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 ...原创 2018-06-01 20:30:35 · 146 阅读 · 0 评论 -
[leetcode]72. Edit Distance
题目链接:https://leetcode.com/problems/edit-distance/#/descriptionGiven two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 st...原创 2017-07-04 18:03:34 · 250 阅读 · 0 评论 -
[lintcode]108. 分割回文串 II
链接:http://www.lintcode.com/zh-cn/problem/palindrome-partitioning-ii/ 给定一个字符串s,将s分割成一些子串,使每个子串都是回文。返回s符合要求的的最少分割次数。您在真实的面试中是否遇到过这个题?Yes样例比如,给出字符串s = "aab",返回 1, 因为进行一次分割可以将字符串s分割成["a...原创 2018-03-20 12:52:36 · 256 阅读 · 0 评论 -
[lintcode]136. 分割回文串
链接:https://lintcode.com/problem/palindrome-partitioning/description描述给定一个字符串s,将s分割成一些子串,使每个子串都是回文串。返回s所有可能的回文串分割方案。您在真实的面试中是否遇到过这个题? 是样例给出 s = "aab",返回[ ["aa", "b"], ["a", "a", ...原创 2018-09-03 12:58:00 · 176 阅读 · 0 评论 -
[leetcode]Group Anagrams
链接:https://leetcode.com/problems/group-anagrams/description/ Given an array of strings, group anagrams together.Example:Input: ["eat", "tea", "tan", "ate", "nat", "bat"],Output:[ [&qu原创 2018-09-01 15:18:11 · 113 阅读 · 0 评论