/** * * @param arr int整型一维数组 the array * @return int整型 */ function maxLength( arr ) { var max = [] var count = 0 for(let i=0;i<arr.length;i++){ if(!max.includes(arr[i])){ max.push(arr[i]) }else{ count = Math.max(count,max.length) max.splice(0,max.indexOf(arr[i])+1) max.push(arr[i]) } } return count } module.exports = { maxLength : maxLength };