JS代码
// 方法 function checkIfArrayIntervalOverLap(area){ let result = false let areaLength = area.length if(areaLength > 0) { let maxStart =[] let minEnd = [] for(var i=0;i<areaLength;i++) { for(var t= 0;t<i;t++){ if(i !== t) { // 不与自身比 maxStart = [area[i][0], area[t][0]];// 开始课时数组 minEnd = [area[i][1], area[t][1]];// 结束课时数组 if(Math.max(...maxStart)<= Math.min(...minEnd)) { return true } } } } } return result } // 例子 const area = [[1,2],[4,10],[11,12]] let result = checkIfArrayIntervalOverLap(area) document.write(result === true?'重叠了':'未重叠')