Company: Salesforce Sde1 Offcampus_23june

Difficulty: medium

Problem Statement

In HackerLand, people are preparing for a parade with a rule that no red uniform can be immediately to the left of a blue one. Given a binary string named color where: '0' represents a person in a red uniform '1' represents a person in a blue uniform The goal is to remove any occurrence of '01' in the string through a specific process: At each second, all substrings '01' in the string are simultaneously changed to '10'. This process repeats until no '01' is present in the string. Calculate the number of seconds it takes for this process to stop. Function Description Complete the function getSwapTime in the editor with the following parameter(s): string color : a binary string that represents the uniform colors of people Returns int: the time to complete the process Constraints 1 ≤ |color| ≤ 3*10^5 where |color| denotes the length of the binary string Input Format for Custom Testing The only line contains the string color . Sample Case 0 Sample Input 0 STDIN FUNCTION ----- -------- 0101

More Salesforce Sde1 Offcampus_23june OA questionsInterview experiences