/**
 * 
 * @param arr int整型一维数组 the array
 * @return int整型
 */
function maxLength( arr ) {
    if (arr.length < 2) {
        return arr.length;
    }
    let windows = {};
    let res = 0;
    let left = -1;
    for (let right = 0; right < arr.length; right++) {
        if (windows[arr[right]] != null) {
            left = Math.max(left ,windows[arr[right]]);
        }
        
        res = Math.max(res, right-left);
        windows[arr[right]] = right;
    }
    return res;
}

module.exports = {
    maxLength : maxLength
};