牛牛的独特子序列
题解
讨论
查看他人的提交
题号:NC207724
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
有一个长度为len只包含小写字母‘a’-'z'的字符串x,现在想要一个特殊的子序列,这个子序列的长度为3*n(n为非负整数),子序列的第
[1,n]个
字母全部为‘a’,
子序列
的[n+1,2*n
]个
字母全部为‘b’,
子序列
的[2*n+1,3*n
]个
字母全部为‘c’,求最长的符合条件的独特子序列的长度是多少。
示例1
输入
复制
"cbacb"
"cbacb"
返回值
复制
0
0
说明
没有符合条件的非空子序列,所以输出0
示例2
输入
复制
"abaabbcccc"
"abaabbcccc"
返回值
复制
6
6
说明
最长的符合条件的子序列为"aabbcc",所以输出6
备注:
牛牛的独特子序列
返回全部题目
列表加载中...
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param x string字符串 * @return int整型 */ public int Maximumlength (String x) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param x string字符串 * @return int整型 */ int Maximumlength(string x) { // write code here } };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # @param x string字符串 # @return int整型 # class Solution: def Maximumlength(self , x ): # write code here
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param x string字符串 * @return int整型 */ function Maximumlength( x ) { // write code here } module.exports = { Maximumlength : Maximumlength };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # @param x string字符串 # @return int整型 # class Solution: def Maximumlength(self , x ): # write code here
package main /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param x string字符串 * @return int整型 */ func Maximumlength( x string ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param x string字符串 * @return int整型 */ int Maximumlength(char* x ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # @param x string字符串 # @return int整型 # class Solution def Maximumlength(x) # write code here end end
"cbacb"
0
"abaabbcccc"
6