字符串
文章平均质量分 78
memcpy0
希望探索文理结合的自由之路。
展开
-
LeetCode 1758. 生成交替二进制字符串的最少操作数【字符串,模拟】1353
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2024-01-02 00:07:40 · 1031 阅读 · 0 评论 -
LeetCode 1759. 统计同质子字符串的数目【字符串】1490
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-11-09 17:09:14 · 347 阅读 · 0 评论 -
LeetCode 301. 删除无效的括号【字符串,回溯或BFS】困难
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-10-30 07:17:13 · 269 阅读 · 0 评论 -
LeetCode 2698. 求一个整数的惩罚数【字符串,回溯,预处理,打表】1678
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-10-29 16:49:26 · 162 阅读 · 0 评论 -
LeetCode 2707. Extra Characters in a String【动态规划,记忆化搜索,Trie】1735
给你一个下标从 0 开始的字符串 和一个单词字典 。你需要将 分割成若干个 互不重叠 的子字符串,每个子字符串都在 中出现过。 中可能会有一些 额外的字符 不在任何子字符串中。请你采取最优策略分割 ,使剩下的字符 最少 。示例 1:示例 2:提示:我们有一个字符串 sss 和一个 dictionarydictionarydictionary 。目标是将 sss 分解为一个或多个不重叠的子字符串,每个子字符串都出现在 dictionarydictionarydictionary 中,并最大限度地原创 2023-09-05 15:36:08 · 320 阅读 · 0 评论 -
LeetCode 2337. Move Pieces to Obtain a String【字符串,双指针】1693
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-08-22 00:06:13 · 194 阅读 · 0 评论 -
LeetCode 833. Find And Replace in String【字符串,哈希表,模拟】1460
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-08-20 17:47:01 · 199 阅读 · 0 评论 -
LeetCode 2490. Circular Sentence【字符串】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-07-03 18:45:32 · 204 阅读 · 0 评论 -
LeetCode 2496. Maximum Value of a String in an Array【字符串,数组】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-06-24 10:54:09 · 333 阅读 · 0 评论 -
LeetCode 2451. Odd String Difference【字符串,哈希表】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-05-25 23:13:27 · 916 阅读 · 0 评论 -
HJ18 识别有效的IP地址和掩码并进行分类统计,HJ39 判断两个IP是否属于同一子网【字符串,模拟】
子网掩码与IP地址结构相同,是32位二进制数,由1和0组成,且1和0分别连续,其中网络号部分全为“1”和主机号部分全为“0”。若IP地址或子网掩码格式非法则输出1,若IP1与IP2属于同一子网络输出0,若IP1与IP2不属于同一子网络输出2。若两台主机的IP地址分别与它们的子网掩码进行逻辑“与”运算(按位与/AND)后的结果相同,则说明这两台主机在同一子网中。每行一个IP地址和掩码,用~隔开。你可以简单的认为子网掩码是一串连续的1和一串连续的0拼接而成的32位二进制数,左边部分都是1,右边部分都是0。原创 2023-04-18 17:04:27 · 541 阅读 · 0 评论 -
LeetCode 1041. Robot Bounded In Circle【字符串,模拟】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的。原创 2023-04-11 14:16:24 · 622 阅读 · 0 评论 -
LeetCode 1616. Split Two Strings to Make Palindrome【字符串,双指针】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。原创 2023-03-18 20:57:38 · 536 阅读 · 0 评论 -
LeetCode 1816. Truncate Sentence【字符串】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库。在这一仓库中,你不仅可以看到LeetCode原题链接、题解代码、题解文章链接、同类.原创 2021-12-06 15:03:03 · 107 阅读 · 0 评论 -
LeetCode 412. Fizz Buzz【字符串/模拟】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库:https://github.com/memcpy0/LeetCode-Conqu.原创 2021-10-14 08:52:51 · 135 阅读 · 0 评论 -
LeetCode 273. Integer to English Words【字符串/模拟】困难
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库:https://github.com/memcpy0/LeetCode-Conqu.原创 2021-10-11 23:45:36 · 163 阅读 · 0 评论 -
LeetCode 2014. Longest Subsequence Repeated k Times【BFS/字符串】困难
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库:https://github.com/memcpy0/LeetCode-Conqu.原创 2021-09-30 01:30:04 · 286 阅读 · 0 评论 -
LeetCode 58. Length of Last Word【模拟/字符串】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库:https://github.com/memcpy0/LeetCode-Conqu.原创 2021-09-29 15:23:53 · 131 阅读 · 0 评论 -
LeetCode 2000. Reverse Prefix of Word【字符串】简单
Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing. For example, if word = "abcdefd"原创 2021-09-13 08:32:27 · 179 阅读 · 0 评论 -
LeetCode 516. Longest Palindromic Subsequence【字符串/动态规划】中等
Given a string s, find the longest palindromic subsequence's length in s.A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.Example 1:Input: s = "bbb原创 2021-09-05 20:25:04 · 163 阅读 · 0 评论 -
LeetCode 165. Compare Version Numbers【字符串/模拟】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库:https://github.com/memcpy0/LeetCode-Conqu.原创 2021-09-02 16:03:40 · 156 阅读 · 0 评论 -
LeetCode C++ 1869. Longer Contiguous Segments of Ones than Zeros【String】简单
Given a binary string s, return true if the longest contiguous segment of 1s is strictly longer than the longest contiguous segment of 0s in s. Return false otherwise. For example, in s = "110100010" the longest contiguous segment of 1s has length 2, and原创 2021-07-04 00:04:03 · 153 阅读 · 2 评论 -
LeetCode 168. Excel Sheet Column Title【数学/字符串】简单
Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet.For example:A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> 28 ...Example 1:Input: columnNumber = 1Output: "A"Example 2:Input:原创 2021-06-30 00:52:00 · 158 阅读 · 0 评论 -
LeetCode 1897. 重新分配字符使所有字符串都相等【字符串,哈希表】1309
You are given an array of strings words (0-indexed).In one operation, pick two distinct indices i and j, where words[i] is a non-empty string, and move any character from words[i] to any position in words[j].Return true if you can make every string in wo原创 2021-06-15 02:09:55 · 157 阅读 · 1 评论 -
LeetCode 984. String Without AAA or BBB【贪心/字符串】中等
Given two integers a and b, return any string s such that: s has length a + b and contains exactly a 'a' letters, and exactly b 'b' letters, The substring 'aaa' does not occur in s, and The substring 'bbb' does not occur in s.Example 1:Input: a = 1,原创 2021-06-13 21:00:30 · 220 阅读 · 0 评论 -
LeetCode 1449. Form Largest Integer With Digits That Add up to Target【动态规划/字符串】困难
Given an array of integers cost and an integer target. Return the maximum integer you can paint under the following rules: The cost of painting a digit (i+1) is given by cost[i] (0 indexed). The total cost used must be equal to原创 2021-06-13 19:08:29 · 169 阅读 · 0 评论 -
LeetCode C++ 1881. Maximum Value after Insertion【贪心/字符串】
You are given a very large integer n, represented as a string, and an integer digit x. The digits in n and the digit x are in the inclusive range [1, 9], and n may represent a negative number.You want to maximize n's numerical value by inserting x a原创 2021-06-01 07:26:40 · 370 阅读 · 0 评论 -
1876. Substrings of Size Three with Distinct Characters【字符串】
A string is good if there are no repeated characters.Given a string s, return the number of good substrings of length three in s.Note that if there are multiple occurrences of the same substring, every occurrence should be counted.A substring原创 2021-06-01 07:02:15 · 224 阅读 · 0 评论 -
1880. Check if Word Equals Summation of Two Words【字符串】
The letter value of a letter is its position in the alphabet starting from 0 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, etc.).The numerical value of some string of lowercase English letters s is the concatenation of the letter values of each letter in s原创 2021-06-01 06:35:06 · 407 阅读 · 0 评论 -
LeetCode C++ 1545. Find Kth Bit in Nth Binary String【String/Recursion】中等
Given two positive integers n and k, the binary string Sn is formed as follows: S1 = "0" Si = Si-1 + "1" + reverse(invert(Si-1)) for i > 1Where + denotes the concatenation opera原创 2021-05-23 03:34:40 · 171 阅读 · 1 评论 -
LeetCode C++ 1864. Minimum Number of Swaps to Make the Binary String Alternating【String/Greedy】中等
Given a binary string s, return the minimum number of character swaps to make it alternating, or -1 if it is impossible.The string is called alternating if no two adjacent characters are equal. For example, the strings "010" and "1010" are alternating, wh原创 2021-05-21 16:45:38 · 251 阅读 · 0 评论 -
LeetCode C++ 1859. Sorting the Sentence【String】简单
A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters.A sentence can be shuffled by appending the 1-indexed word position to each word then rear原创 2021-05-18 01:14:37 · 483 阅读 · 0 评论 -
LeetCode C++ 13. Roman to Integer【String/Hash Table】简单
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D 500M 1000For example, 2 is writt原创 2021-05-16 02:16:03 · 166 阅读 · 0 评论 -
LeetCode C++ 791. Custom Sort String【String/Sort】中等
S and T are strings composed of lowercase letters. In S, no letter occurs more than once.S was sorted in some custom order previously. We want to permute the characters of T so that they match the order that S was sorted. More specifically, if x occurs be原创 2021-05-05 21:01:54 · 140 阅读 · 0 评论 -
LeetCode C++ 820. Short Encoding of Words【String/Trie】中等
A valid encoding of an array of words is any reference string s and array of indices indices such that: words.length == indices.length The reference string s ends with the '#' character. For each index indices[i], the substring of s starting from indic原创 2021-05-05 04:45:50 · 191 阅读 · 0 评论 -
LeetCode C++ 1790. Check if One String Swap Can Make Strings Equal【String】简单
You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices.Return true if it is possible to make both strings equal by pe原创 2021-05-04 21:45:15 · 183 阅读 · 0 评论 -
LeetCode C++ 1844. Replace All Digits with Characters【String】简单
You are given a 0-indexed string s that has lowercase English letters in its even indices and digits in its odd indices.There is a function shift(c, x), where c is a character and x is a digit, that returns the xth character after c. For example, shift(原创 2021-05-04 01:41:24 · 207 阅读 · 0 评论 -
LeetCode C++ 1736. Latest Time by Replacing Hidden Digits【String/Greedy】简单
You are given a string time in the form of hh:mm, where some of the digits in the string are hidden (represented by ?).The valid times are those inclusively between 00:00 and 23:59.Return the latest valid time you can get from time by replacing the hidd原创 2021-05-02 01:38:01 · 177 阅读 · 0 评论 -
LeetCode C++ 1784. Check if Binary String Has at Most One Segment of Ones【String】简单
Given a binary string s without leading zeros, return true if s contains at most one contiguous segment of ones. Otherwise, return false.Example 1:Input: s = "1001"Output: falseExplanation: The ones do not form a contiguous segment.Example 2:原创 2021-05-02 01:27:15 · 151 阅读 · 0 评论 -
LeetCode C++ 1832. Check if the Sentence Is Pangram【String】简单
全字母句 指包含英语字母表中每个字母至少一次的句子。给你一个仅由小写英文字母组成的字符串 sentence ,请你判断 sentence 是否为 全字母句 。如果是,返回 true ;否则,返回 false 。原创 2021-05-02 00:35:49 · 196 阅读 · 0 评论