长度为 K 的重复字符子串
题解
讨论
查看他人的提交
题号:NC227731
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
给你一个由小写字母组成的长度为n的字符串
S
,找出所有长度为
k
且包含重复字符的子串,请你返回全部满足要求的子串的
数目
。
数据范围:
,
进阶: 时间复杂度
,空间复杂度
示例1
输入
复制
"createfunonyoka",4
"createfunonyoka",4
返回值
复制
4
4
示例2
输入
复制
"yokagames",3
"yokagames",3
返回值
复制
1
1
示例3
输入
复制
"yoka",4
"yoka",4
返回值
复制
0
0
长度为 K 的重复字符子串
返回全部题目
列表加载中...
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @param k int整型 * @return int整型 */ public int numKLenSubstrRepeats (String s, int k) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @param k int整型 * @return int整型 */ int numKLenSubstrRepeats(string s, int k) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param s string字符串 # @param k int整型 # @return int整型 # class Solution: def numKLenSubstrRepeats(self , s , k ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @param k int整型 * @return int整型 */ public int numKLenSubstrRepeats (string s, int k) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @param k int整型 * @return int整型 */ function numKLenSubstrRepeats( s , k ) { // write code here } module.exports = { numKLenSubstrRepeats : numKLenSubstrRepeats };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param s string字符串 # @param k int整型 # @return int整型 # class Solution: def numKLenSubstrRepeats(self , s: str, k: int) -> int: # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @param k int整型 * @return int整型 */ func numKLenSubstrRepeats( s string , k int ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @param k int整型 * @return int整型 */ int numKLenSubstrRepeats(char* s, int k ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param s string字符串 # @param k int整型 # @return int整型 # class Solution def numKLenSubstrRepeats(s, k) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @param k int整型 * @return int整型 */ def numKLenSubstrRepeats(s: String,k: Int): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @param k int整型 * @return int整型 */ fun numKLenSubstrRepeats(s: String,k: Int): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @param k int整型 * @return int整型 */ public int numKLenSubstrRepeats (String s, int k) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @param k int整型 * @return int整型 */ export function numKLenSubstrRepeats(s: string, k: number): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @param k int整型 * @return int整型 */ func numKLenSubstrRepeats ( _ s: String, _ k: Int) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @param k int整型 * @return int整型 */ pub fn numKLenSubstrRepeats(&self, s: String, k: i32) -> i32 { // write code here } }
"createfunonyoka",4
4
"yokagames",3
1
"yoka",4
0