Algorithm · Microsoft · Medium
Given an integer array items that contains only the values 0, 1, and 2, where each value represents a category, rearrange the array in place so that all 0 values appear before any 1 value, and all 1 values appear before any 2 value. You must modify the original array directly; do not allocate a second array for the output. For testing, return the modified array after the grouping is complete. Your solution should run in $$O(n)$$ time, use only $$O(1)$$ extra memory, and…
Checking your access…