Back to problems

Zero Compaction Array Coding

Algorithm · JPMorgan · Easy

Requirements Accept an integer array and relocate every zero to the array's far end. The non-zero entries must appear in the same relative order as before. For the standard form of the problem, modify the array in place. Follow the usual Move Zeroes behavior. A possible function signature is: Examples Example 1 The non-zero values retain their original order, and both zeroes are placed after them. Example 2 Because the array contains no zeroes, it remains unchanged. Example…

Checking your access…