คำอธิบายโจทย์
เขียน 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
}