/**
 * 
 * @param arr int整型一维数组 the array
 * @return int整型
 */
function maxLength( arr ) {
    // write code here
    if(arr.length === 0) return 0;
    let max = 0;
    const map = new Map();
    for(let i = 0, j = 0; i < arr.length; ++i) {
        if(map.has(arr[i])) {
            j = Math.max(j, map.get(arr[i]) + 1);
        }
        map.set(arr[i], i);
        max = Math.max(max, i-j+1);
    }
    return max;
}
module.exports = {
    maxLength : maxLength
};