牛客题霸-算法篇
找到字符串的最长无重复字符子串
相似的企业真题
时间限制:C/C++ 2秒,其他语言4秒
空间限制:C/C++ 256M,其他语言512M
热度指数:39129
本题知识点:
哈希
双指针
字符串
算法知识视频讲解
校招时部分企业笔试将禁止编程题跳出页面,为提前适应,练习时请使用在线自测,而非本地IDE。
题目描述
给定一个数组arr,返回arr的最长无的重复子串的长度(无重复指的是所有数字都不相同)。
示例1
输入
复制
[2,3,4,5]
[2,3,4,5]
返回值
复制
4
4
示例2
输入
复制
[2,2,3,4,3]
[2,2,3,4,3]
返回值
复制
3
3
备注:
上一题
下一题
登录
/
注册
我的提交
编辑器加载中...
import java.util.*; public class Solution { /** * * @param arr int整型一维数组 the array * @return int整型 */ public int maxLength (int[] arr) { // write code here } }
class Solution { public: /** * * @param arr int整型vector the array * @return int整型 */ int maxLength(vector
& arr) { // write code here } };
# # # @param arr int整型一维数组 the array # @return int整型 # class Solution: def maxLength(self , arr ): # write code here
/** * * @param arr int整型一维数组 the array * @return int整型 */ function maxLength( arr ) { // write code here } module.exports = { maxLength : maxLength };
# # # @param arr int整型一维数组 the array # @return int整型 # class Solution: def maxLength(self , arr ): # write code here
package main /** * * @param arr int整型一维数组 the array * @return int整型 */ func maxLength( arr []int ) int { // write code here }
/** * * @param arr int整型一维数组 the array * @param arrLen int arr数组长度 * @return int整型 */ int maxLength(int* arr, int arrLen ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # @param arr int整型一维数组 the array # @return int整型 # class Solution def maxLength(arr) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param arr int整型一维数组 the array * @return int整型 */ def maxLength(arr: Array[Int]): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param arr int整型一维数组 the array * @return int整型 */ fun maxLength(arr: IntArray): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param arr int整型一维数组 the array * @return int整型 */ public int maxLength (int[] arr) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param arr int整型一维数组 the array * @return int整型 */ export function maxLength(arr: number[]): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param arr int整型一维数组 the array * @return int整型 */ func maxLength ( _ arr: [Int]) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param arr int整型一维数组 the array * @return int整型 */ pub fn maxLength(&self, arr: Vec
) -> i32 { // write code here } }
[2,3,4,5]
4
[2,2,3,4,3]
3