ICode9

精准搜索请尝试: 精确搜索
  • leetcode 647. Palindromic Substrings回文子串(中等)2022-08-27 22:00:42

    一、题目大意 给你一个字符串 s ,请你统计并返回这个字符串中 回文子串 的数目。 回文字符串 是正着读和倒过来读一样的字符串。 子字符串 是字符串中的由连续字符组成的一个序列。 具有不同开始位置或结束位置的子串,即使是由相同的字符组成,也会被视作不同的子串。 示例 1: 输入:s =

  • [Oracle] LeetCode 696 Count Binary Substrings2022-08-24 06:31:01

    Given a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively. Substrings that occur multiple times are counte

  • LeetCode 828. Count Unique Characters of All Substrings of a Given String2022-07-26 06:00:06

    原题链接在这里:https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string/ 题目: Let's define a function countUniqueChars(s) that returns the number of unique characters on s. For example, calling countUniqueChars(s) if s =

  • LeetCode 2262. Total Appeal of A String2022-07-25 09:03:03

    原题链接在这里:https://leetcode.com/problems/total-appeal-of-a-string/ 题目: The appeal of a string is the number of distinct characters found in the string. For example, the appeal of "abbca" is 3 because it has 3 distinct characters: 'a', &#

  • Count Subarray by Element2022-06-27 07:32:09

    2262. Total Appeal of A String Hard The appeal of a string is the number of distinct characters found in the string. For example, the appeal of "abbca" is 3 because it has 3 distinct characters: 'a', 'b', and 'c

  • Codeforces 1276F. Asterisk Substrings (3400)2022-06-10 21:01:50

    给定一个全由小写字母组成的字符串 \(s\),设 \(t_i\) 表示将 \(s\) 中的第 \(i\) 个字符替换成 \(*\) 后得到的字符串,求字符串集合 \(\{s,t_1,\ldots,t_{|s|}\}\) 的本质不同的子串数量(包含空串)。 \(1\le |s|\le 10^5\)。 首先答案的构成一定是 \(\{\empty,*,s*,*s,s*t\}\) 五种

  • 02.08 Longest Regular Bracket Sequence2022-02-09 21:58:19

    最长的常规支架序列|断续器 (jxnu.edu.cn)https://acs.jxnu.edu.cn/problem/CF5C 描述: This is yet another problem dealing with regular bracket sequences. We should remind you that a bracket sequence is called regular, if by inserting «+» and «1» into it we c

  • 647. Palindromic Substrings2022-02-03 11:02:29

    This is a "palindromic" problem, I think DP can solve this problem, but there is a easier way to solve it, the time complexity is O(n2): private int res = 0; public int countSubstrings(String s) { for(int i=0;i<s.length();i++

  • 696. Count Binary Substrings2022-01-20 05:02:07

    这道题,最重要的是要能观察出,连续的0和连续的1之间的关系——每一组连续的0和连续的1可以贡献出:Math.min(连续0,连续1) 下面的两个算法都可以beat 100%,时间复杂度O(n). public int countBinarySubstrings(String s) { int res = 0; int cur = 1, pre = 0;

  • 【Codeforces】550A-Two Substrings2021-12-29 04:33:33

    每天随机做一道CF题并写题解,希望有朝一日能拿块牌子(rating:1300~1800) 原题链接:Codeforces 550A-Two Substrings 题意:给你一个字符串s,你需要判断字符串s中是否含有子串"BA"和"AB",且这两个子串是不重叠的。 思路:对于字符串s,"BAB"和"ABA"都可以被认为是"BA"和"AB"中的任意一种,所以

  • Codeforces 961F - k-substrings(二分+哈希)2021-10-16 18:02:57

    Codeforces 题面传送门 & 洛谷题面传送门 介绍一种奇怪的 \(\Theta(n\log n)\) 的奇怪做法。 注意到这个“border 的长度必须是奇数”的条件非常奇怪,同时我们待求解的字符串也有一些比较奇妙的性质——它们的左右端点都关于中线轴对称,即 \(l+r=n+1\)。我们考虑 border 的性质与 \(

  • CF1270F - Awesome Substrings(思维)2021-09-12 08:31:05

    题目 给定一个01串,问有多少连续子串中1的个数大于0且可以整除其长度。 题解 问题等价于\(r-l=k(pre[r]-pre[l])\),即\(r-k\cdot pre[r]=l-k\cdot pre[l]\)。假设固定一个值\(T\),当\(k<T\)时,可以枚举\(k\)统计有多少相同数对,时间复杂度\(O(nT)\)。 由于\(pre[r]-pre[l] =\frac{r-l}{

  • 【ABC214F】Substrings2021-08-15 10:00:15

    传送门 最近的 ABC 题目质量都好高啊,最后两题都吊打我。 不过 ABC214D 撞题 CF915F 喽。 题意: 给定长度为 \(n\) 的字符串,求本质不同的子序列数模 \(10^9+7\)。一个子序列必须满足不存在两个位置在原串中相邻。 Data range:\(n \le 2\,\times\,10^5\) 分析: 感谢 ABC 教会我一种新的

  • <题解> CF1276F Asterisk Substrings2021-08-08 07:00:33

    前言 不得不说,这个题真的难,但是在我的不懈坚持之下还是被我给调出来了。 这就是专属于我们的快乐吧,在你做出题的那一刻,欣喜若狂。 解法 统计本质不同的字串数,第一眼看上去是懵的,不知道该从哪里下手,甚至想用广义SAM。 但是其实不用那么麻烦。 我们将子串分为四类,S,S,S,ST,最后算上

  • 2021-7-25 Two Substrings2021-07-25 23:32:59

    难度 1500 题目 Codeforces: A. Two Substrings time limit per test 2 seconds memory limit per test 256 megabytes You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA&quo

  • 题解 CF550A【Two Substrings】2021-06-18 18:02:47

    概述 题号 难度 \(AC\)时间及记录 \(\texttt{CF550A}\) \(\texttt{洛谷难度:普及/提高-}\) \(\texttt{On 2021/06/14}\) 解析 这道题目题目意思不难理解, 我们看到样例一就知道了选择的 \(AB\) 和 \(BA\) 位置不能冲突。 所以说我们只有两种情况: 先找 \(AB\),再找 \(BA\)

  • CF1276F - Asterisk Substrings2021-05-09 08:32:56

    CF1276F - Asterisk Substrings 题目大意 给定串\(S,|S|=n\),设一个串的子串集合为\(Sub(S)\) 求\(|Sub(S) \cup Sub(*+S[2:n])\cup Sub(S[1:1]+*+S[3:n])\cup \cdots|\) 其中*表示特殊字符而不是通配符 分析 对于不包含*的串,显然就是\(Sub(S)\),可以通过后缀数组,后缀自动机来计算

  • CF1029A Many Equal Substrings2021-05-01 12:35:41

    题目描述: 你有一个字符串t,它由n个字母组成。 定义一个字符串s的子串为\(s[l...r]\),表示从位置l到r构成的一个新的串。 你的目标是构造一个字符串s,使得它的可能长度最小,要求s中存在k个位置i,可以找到k个以i为出发点的子串t。 输入: 第一行输入两个整数n和k,表示t的长度和需要k个子串

  • SPOJ694 Distinct Substrings2021-04-27 19:34:40

    【题意】 求不相同的子串的个数 【分析】 考虑每一个后缀的前缀表示了所有的子串,有n*(n+1)/2个 减去重复的即可,也就是所有的height之和 【代码】 #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; const int

  • [LeetCode] 1593. Split a String Into the Max Number of Unique Substrings2021-01-07 02:02:36

    Given a string s, return the maximum number of unique substrings that the given string can be split into. You can split string s into any list of non-empty substrings, where the concatenation of the substrings forms the original string. However, you m

  • leetcode 647. Palindromic Substrings(python)2020-12-21 14:59:48

    描述 Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters. Example 1: Input: "abc"

  • leetcode 647. Palindromic Substrings(python)2020-12-21 14:58:26

    描述 Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters. Example 1: Input: "abc"

  • leetcode 647. Palindromic Substrings(回文子串)2020-11-27 22:33:33

    Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters. Example 1: Input: “abc” Output: 3

  • 647. Palindromic Substrings2020-11-06 23:01:42

    package LeetCode_647 /** * 647. Palindromic Substrings * https://leetcode.com/problems/palindromic-substrings/ * Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end i

  • Problem 550A - Two Substrings2020-08-18 17:31:38

    A - Two Substrings You are given string s. Your task is to determine if the given strings contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). Input The only line of input contains a string s of l

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有