题目说明
编写 function solution(items, cursor, size)。输入输出均为 JSON 值,不要修改输入数组或对象。不支持外部库、网络访问及异步函数。 items:{id:string,...JSON}[] with unique IDs; cursor:string|null; size:number. Use 10 for a nonpositive/noninteger size and cap at 100. A null cursor starts at the beginning; otherwise start AFTER its matching ID. Unknown cursor yields {items:[],nextCursor:null}. Return the last returned ID as nextCursor only if more items remain. Never mutate input. 输入范围:每个输入数组最多50,000项,每个字符串最多1,000个字符。数字必须有限,整数及整数累计结果在JavaScript安全整数范围内。其他类型和有效性遵循上述规则。
输入输出示例
示例 1
函数参数
[
[
{
"id": "a"
},
{
"id": "b"
},
{
"id": "c"
}
],
null,
2
]返回值
{
"items": [
{
"id": "a"
},
{
"id": "b"
}
],
"nextCursor": "b"
}示例 2
函数参数
[
[
{
"id": "a"
},
{
"id": "b"
}
],
"a",
1
]返回值
{
"items": [
{
"id": "b"
}
],
"nextCursor": null
}示例 3
函数参数
[
[
{
"id": "__proto__"
}
],
null,
1
]返回值
{
"items": [
{
"id": "__proto__"
}
],
"nextCursor": null
}