Problem statement
Write function solution(items, cursor, size). Inputs and outputs are JSON values. Do not modify input arrays or objects. External libraries, network access, and asynchronous functions are not supported. 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. Input limits: at most 50,000 items per input array and 1,000 characters per string. Numbers are finite; integers and accumulated integer results stay in the JavaScript safe-integer range. Other types and validity rules follow the statement above.
Example input and output
Example 1
Function arguments
[
[
{
"id": "a"
},
{
"id": "b"
},
{
"id": "c"
}
],
null,
2
]Return value
{
"items": [
{
"id": "a"
},
{
"id": "b"
}
],
"nextCursor": "b"
}Example 2
Function arguments
[
[
{
"id": "a"
},
{
"id": "b"
}
],
"a",
1
]Return value
{
"items": [
{
"id": "b"
}
],
"nextCursor": null
}Example 3
Function arguments
[
[
{
"id": "__proto__"
}
],
null,
1
]Return value
{
"items": [
{
"id": "__proto__"
}
],
"nextCursor": null
}