Publicis Sapient, Recently Asked Online Assessments in 22 Nov, 2025 | Maximize Consecutive Ones

Publicis-Sapient · Question · Posted Apr 2026

Question: Maximize Consecutive Ones Problem Statement: Implement a function that determines the maximum number of consecutive '1's that can be achieved in a given binary string s of length n after performing an operation on at most one substring. An operation consists of: Selecting a substring of length k and changing all its '0's to '1's. The function getMaximumConsecutiveOnes will take two inputs: string s: the given binary string int k: the length of the substring that can be modified ...

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

Log in Create a free account