Freshworks SWE Interview Question 2022 August | Arrays | on-campus

Question · Posted Jun 2026

Question 1: Sort Colors Problem Statement Given an array nums with n objects colored red, white, or blue, represented by the integers 0, 1, and 2 respectively, sort them in-place so that objects of the same color are adjacent, with the colors in the order red (0), white (1), and blue (2). You must solve this without using the library's sort function and in a single pass using O(1) extra space. Constraints n == nums.length 1 <= n <= 300 ...

The full answer & interview discussion are available to premium members.

Log in Create a free account