← Samsung questions

Sort an array of 10,000 elements containing only 1s, 2s, and 3s in O(n) time

Filed under Samsung

Given an array of 10,000 elements containing only the values 1, 2, and 3, sort the array in-place with O(n) time complexity and O(1) extra space. This is a variation of the Dutch National Flag…

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Samsung questions

Collected from public candidate posts and coding forums. Updated Nov 2026.