牛牛有一个只包含A、B、C三个字符的字符串,牛牛想找到其中包含A、B、C这三个字符的最短子串的长度,只不过他不知道该如何解答,所以他想请你帮忙。 给定一个只包含A、B、C三个字符的字符串,返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。
示例1
输入
"ABC"
输出
3
说明
包含A、B、C这三个字符的最短子串的长度为3。
示例2
输入
"AAA"
输出
0
说明
不存在包含A、B、C这三个字符的子串,返回0。
加载中...
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 * @param s string字符串 代表题中所述字符串 * @return int整型 */ public int findMinLength (String s) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 * @param s string字符串 代表题中所述字符串 * @return int整型 */ int findMinLength(string s) { // write code here } };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 # @param s string字符串 代表题中所述字符串 # @return int整型 # class Solution: def findMinLength(self , s ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 * @param s string字符串 代表题中所述字符串 * @return int整型 */ public int findMinLength (string s) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 * @param s string字符串 代表题中所述字符串 * @return int整型 */ function findMinLength( s ) { // write code here } module.exports = { findMinLength : findMinLength };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 # @param s string字符串 代表题中所述字符串 # @return int整型 # class Solution: def findMinLength(self , s ): # write code here
package main /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 * @param s string字符串 代表题中所述字符串 * @return int整型 */ func findMinLength( s string ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 * @param s string字符串 代表题中所述字符串 * @return int整型 */ int findMinLength(char* s ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 # @param s string字符串 代表题中所述字符串 # @return int整型 # class Solution def findMinLength(s) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 * @param s string字符串 代表题中所述字符串 * @return int整型 */ def findMinLength(s: String): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 * @param s string字符串 代表题中所述字符串 * @return int整型 */ fun findMinLength(s: String): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 * @param s string字符串 代表题中所述字符串 * @return int整型 */ public int findMinLength (String s) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 * @param s string字符串 代表题中所述字符串 * @return int整型 */ export function findMinLength(s: string): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 * @param s string字符串 代表题中所述字符串 * @return int整型 */ func findMinLength ( _ s: String) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 返回其中包含A、B、C这三个字符的最短子串的长度,如果不存在该子串,请返回0。 * @param s string字符串 代表题中所述字符串 * @return int整型 */ pub fn findMinLength(&self, s: String) -> i32 { // write code here } }
"ABC"
3
"AAA"
0