Turing, Recently Asked Online Assessments in 07 Feb, 2026 | Consecutive 1s via Adjacent Swaps | Coding Assessment | Complete Solutions & Tips
Question · Posted Mar 2026
Question: Consecutive 1s Problem Statement: You are given an array, n as input. The values in the array are either 1 or 0. You are also provided with another input, c, an integer. We are allowed to exchange adjacent elements in the original array. By a series of such exchanges, we are required to form c consecutive 1's. Return the minimum number of exchanges to achieve this. Return 0 if the original array already has c consecutive 1's. Example 1: ...
The full answer & interview discussion are available to premium members.
Log in Create a free account