คำอธิบายโจทย์
เขียน function solution(tokens, size, overlap) ข้อมูลเข้าและผลลัพธ์เป็นค่า JSON ห้ามแก้ไขอาร์เรย์หรือออบเจ็กต์ข้อมูลเข้า ไม่รองรับไลบรารีภายนอก เครือข่าย หรือฟังก์ชันแบบอะซิงโครนัส tokens:JSON[], size:integer 1–1024, overlap:integer 0<=overlap<size. Start at 0 and advance by size-overlap. Each chunk is {start,end,tokens}, with end=min(length,start+size) exclusive. Stop immediately after a chunk reaches the input end. Empty input yields []. Preserve JSON tokens without joining or string conversion. ขอบเขตข้อมูล: อาร์เรย์อินพุตแต่ละชุดมีไม่เกิน 50,000 รายการ สตริงไม่เกิน 1,000 ตัวอักษร ตัวเลขต้องเป็นค่าจำกัด จำนวนเต็มและผลรวมจำนวนเต็มอยู่ในช่วงจำนวนเต็มที่ปลอดภัยของ JavaScript ชนิดและความถูกต้องอื่นเป็นไปตามกฎด้านบน
ตัวอย่างข้อมูลเข้าและผลลัพธ์
ตัวอย่าง 1
อาร์กิวเมนต์ของฟังก์ชัน
[
[
"a",
"b",
"c",
"d",
"e"
],
3,
1
]ค่าที่ส่งคืน
[
{
"start": 0,
"end": 3,
"tokens": [
"a",
"b",
"c"
]
},
{
"start": 2,
"end": 5,
"tokens": [
"c",
"d",
"e"
]
}
]ตัวอย่าง 2
อาร์กิวเมนต์ของฟังก์ชัน
[
[
"a",
"b",
"c",
"d"
],
2,
0
]ค่าที่ส่งคืน
[
{
"start": 0,
"end": 2,
"tokens": [
"a",
"b"
]
},
{
"start": 2,
"end": 4,
"tokens": [
"c",
"d"
]
}
]ตัวอย่าง 3
อาร์กิวเมนต์ของฟังก์ชัน
[
[
null,
true
],
3,
0
]ค่าที่ส่งคืน
[
{
"start": 0,
"end": 2,
"tokens": [
null,
true
]
}
]