Reported September 2026
Microsoftsimulation

Copy File Bytes with Partial Writes

Reported by candidates from Microsoft's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Microsoft OA. Under 2s to a working solution.
Founder's read

Microsoft reportedly put this one in front of candidates in September 2026, and it looks scarier than it is. Strip the file-copy costume and the problem reduces to this: return a copy of the input array. The chunked reads and partial writes are simulation noise, and the output always equals the source. If you've got an OA invite and you're bracing for something clever, relax. The risk here is overthinking it or writing a loop that stalls. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but this one you can probably handle cold.

The problem

Simulate the core data loop of a file-copy command. source contains the source file's bytes as integers from 0 through 255.
Read at most readChunkSize bytes at a time. A single write accepts at most maxWriteSize bytes, so keep writing until the entire current read buffer is stored. Return the destination bytes after the copy completes.

Function
copyFileBytes(source: int[], readChunkSize: int, maxWriteSize: int) → int[]

Examples
Example 1
source = [0,255,1,2,3]
readChunkSize = 3
maxWriteSize = 2
return = [0,255,1,2,3]
The first three-byte read requires two writes, but no byte is lost.
Example 2
source = []
readChunkSize = 4
maxWriteSize = 1
return = []
An empty source creates an empty destination.

Constraints
0 <= source.length <= 100000.
1 <= readChunkSize, maxWriteSize <= 100000.
Every source value is between 0 and 255.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: nothing is ever dropped, so the destination is the source in the same order. Both examples confirm it. The pattern is simulation, and the honest solution is a nested loop. The outer loop advances by readChunkSize. The inner loop writes up to maxWriteSize bytes from the current buffer until it's empty, appending each slice to the destination. The common pitfall is an infinite loop from not advancing the write offset, or an off-by-one at the final partial chunk. Empty input must return an empty array, and the loops handle that naturally. Complexity is O(n) time and O(n) space. Don't build a clever slicing helper that risks a bug. Plain index arithmetic with min() is enough. If you freeze on the loop bounds during the live OA, StealthCoder is the hedge that hands you the working version in seconds.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Copy File Bytes with Partial Writes cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Microsoft's OA.

Microsoft reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Copy File Bytes with Partial Writes FAQ

How hard is the Microsoft copy file bytes problem really?+

Easy. The output always equals the source array, so the difficulty is purely writing a clean simulation without an off-by-one. If you can write a nested loop with a min() on the chunk end, you're done. Expect it to be a warm-up style question, not a pattern puzzle.

What's the trick to copyFileBytes?+

Realize no bytes are lost or reordered. Reading in chunks and writing in partial pieces only changes how many steps it takes, not the result. You can simulate it faithfully or just copy the array, but simulating shows you understood the setup.

Should I simulate the reads and writes or just return a copy?+

Simulate it. Returning a copy passes the tests, but the problem asks you to model the loop, and a reviewer may care. Write the outer chunk loop and the inner write loop. It's about ten lines and costs you nothing extra.

What edge cases break this?+

Empty source, which must return an empty array. A readChunkSize larger than the source length. A maxWriteSize larger than the chunk. And the last chunk being shorter than readChunkSize. Use min(start + size, end) for every boundary and these all work.

How do I prepare for this in 48 hours?+

Practice simple simulation problems with chunked or windowed iteration. Write the nested loop from memory twice, then test with the two examples and a case where sizes don't divide evenly. That's enough. Don't burn time on advanced algorithms for this one.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Microsoft.

OA at Microsoft?
Invisible during screen share
Get it