腾讯前端暑期实习笔试编程题
第一题代码:
function test(N, arr) {
let res = []
while (arr.length > 0) {
if (arr[0] == N) {
if (res == []) {
console.log(arr[0])
N--
arr.shift()
} else {
let result = ''+arr[0]
N--
arr.shift()
while (res.length > 0) {
if (res[0] == N) {
result = result+ ' ' + res[0]
N--
res.shift()
}else{
break
}
}
if(result !=''){
console.log(result)
}
}
} else {
console.log(' ')
res.push(arr[0])
res.sort((a,b)=>b-a)
arr.shift()
}
}
}
let N = 15
let arr = [10,15,12,14,5, 11,1,13, 8, 9, 7, 6, 4, 2, 3]
test(N, arr)
#腾讯##笔试题目#

影石Insta360公司氛围 452人发布
查看6道真题和解析