Copy Non-overlapping Byte Buffers
Problem statement
The independent arrays destination and source represent non-overlapping byte buffers. Replace the first count destination bytes with the corresponding source bytes and return the complete destination buffer. Preserve its length and every byte after the copied prefix.
A byte is represented by an integer from 0 through 255. Zero is ordinary data. With count zero, copy nothing. The source buffer must remain unchanged. The judge supplies separate buffers; overlapping memory is outside this contract.
Function
copyBytes(destination: int[], source: int[], count: int) → int[]Examples
Example 1
destination = [9,9,9,9]source = [1,0,255]count = 3return = [1,0,255,9]The first three bytes become 1, 0 and 255. The last byte remains 9.
Example 2
destination = [5,6]source = [2,3]count = 0return = [5,6]Copying zero bytes preserves both destination bytes.
Constraints
0 <= destination.length <= 1000.0 <= source.length <= 1000.0 <= destination[i] <= 255.0 <= source[i] <= 255.0 <= count <= 1000.count <= destination.length.count <= source.length.