Company: Infosys SP
Difficulty: medium
Light Road Walking Problem You are given a road of length n . The road is represented as an array v of length n . Each position i from 1 to n has a light. Each light is either 1 (turned on) or 0 (turned off). You love to walk, so you can choose any positions i and j ( i < j ) and walk from i to j . You can do one of the following two moves: If you are at position i and the light at i+1 is turned on, you can move to i+1 . If you are at position i and the light at i+1 is turned off, you must stay at i . Each move takes 1 second , and in each second, all lights reverse (if the light is 1, it becomes 0 and vice versa). Now, for every i and j ( 0 ≤ i < j ≤ n ), you should calculate the number of seconds you need to move from i to j and store it in an array a . Find the sum of a . Since the answer can be large, return it mod 1e9 + 7 . Input Format The first line contains an integer n , denoting the number of elements in v . Each line i of the n subsequent lines contains an integer desc