FastPrepCopy Non-overlapping Byte Buffers
Problems/Copy Non-overlapping Byte Buffers

Copy Non-overlapping Byte Buffers

AMD logoAMD● EasyINTERNNEW GRADPHONE SCREENONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for memcpy in C. This portable exercise grades non-overlapping byte-copy semantics using integer buffers; it does not grade raw C pointer syntax or overlapping memory. Bounds and interface are authored; approximate source match 75%.

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.

More AMD problems

  • Insert After a Linked-List NodeONSITE INTERVIEW · Seen Oct 2026
  • LRU CacheONSITE INTERVIEW · Seen Oct 2026
  • Lowest Common Ancestor of a Binary TreePHONE SCREEN · Seen Oct 2026
All AMD interview questionsSee AMD hiring insights
Saved
public int[] copyBytes(int[] destination, int[] source, int count) {
    // Write your code here.
}
Checking account…