Company: Infosys SP
Difficulty: medium
Light Road Walking Problem Picture a corridor made up of n segments, described by an array v of length n . Each spot i from 1 to n holds a signal lamp, and every lamp reads either 1 (lit) or 0 (unlit). Given any two boundary points i and j along the corridor with i < j , you plan a trip from i to j . The trip follows one of these two rules at each moment: If you stand at position i and the lamp at i+1 is lit, you advance to i+1 . If you stand at position i and the lamp at i+1 is unlit, you remain at i . Each attempted step costs 1 second , and at the close of every second, every lamp flips its reading (a 1 turns into a 0 and a 0 turns into a 1). For each pair i , j with 0 ≤ i < j ≤ n , work out the number of seconds the trip from i to j takes, and record it as entry in an array a . Report the total of all entries in a . Because this total may be huge, give it mod 1e9 + 7 . Input Format The first line contains an integer n , denoting the number of elements in v . Each line i of th