Company: Google_IITR
Difficulty: medium
Trim zeroes Problem Description You are given a string S of length N consisting of only '0' and '1'. You are given Q queries of two different types: type 1 and position = D and integer X If X = 1 , change the character at D to '1'. If X = 0 , change the character at D to '0'. type 2 and position = l and position = r Let A be the substring of S containing all the characters from index l to r . Find the length of the longest substring of A which has both the starting and ending character as '1'. Task Determine the answer for each type 2 query in the given order. Notes 1-based indexing is followed. Queries are dependent and processed in the given order. A substring is a contiguous sequence of characters within a string. For example, the substrings of the string "010" are "0", "1", "0", "01", "10" and "010". Examples Example 1: Assumptions: N = 5 S = "01011" Q = 5 Query = [[2, 2, 3], [2, 1, 5], [1, 5, 0], [2, 4, 4], [2, 1, 5]] Approach: Initially, S = 01011 In the 1 st query, A = "10" . He