有没有办法将数字列表分组为带下划线的数字区间?
// Input:
var arr = [0,1,2,8];
var interval = 3;
// Output:
// There are 3 numbers from 0 to <3
// There are 0 numbers from 3 to <6
// There is 1 number from 6 to <9
// Returns [3, 0, 1]
Run Code Online (Sandbox Code Playgroud)
我注意到一些解决方案不会测试更大的值.尝试第二个测试用例:
var arr = [110,113,116,119];
Run Code Online (Sandbox Code Playgroud)