算法汇编 freedomlike9 2024-10-20 57 阅读1分钟 1、解决环形(首尾相连) 1、采用模运算 const left = current[(i - 1 + n) % n]; const right = current[(i + 1) % n]; // n为数组长度,i为数组索引,用模运算即可解决数组环形问题,获得其左右邻居的值