Lamps stand in one row along a street. Each lamp is either lit or dark.
A repair crew visits only once. It repairs one block of exactly blockSize neighbouring lamps, so every lamp in that block is lit after the visit. The whole block must be inside the street. It may include lamps that were already lit, and lamps outside the block do not change.
Pick the block that gives the street the longest possible stretch of neighbouring lit lamps.
int longestLitStretch(String lamps, int blockSize)
lamps[i] is 'L' if lamp i is lit and 'D' if it is dark. Lamps are numbered from 0, left to right.1 ≤ blockSize ≤ lamps.length ≤ 100,000lamps contains only 'L' and 'D'.Input: longestLitStretch(lamps = "LLDDLLLDL", blockSize = 2)
Output: 7
Explanation: Repair lamps 2 and 3. The street becomes "LLLLLLLDL", so lamps 0 to 6 form a lit stretch of 7. Repairing lamps 7 and 8 instead gives only 5 lit lamps in a row.
Input: longestLitStretch(lamps = "DLLDLLD", blockSize = 3)
Output: 5
Explanation: Repair lamps 2 to 4. Lamps 2 and 4 were already lit and lamp 3 starts working, so the street becomes "DLLLLLD" and lamps 1 to 5 are lit.
Input: longestLitStretch(lamps = "LDDDDDLLL", blockSize = 3)
Output: 6
Explanation: One block of 3 cannot fix all 5 dark lamps in the middle. Repairing lamps 3 to 5 makes the street "LDDLLLLLL", so lamps 3 to 8 are lit.
Input: longestLitStretch(lamps = "LLDLLLDLL", blockSize = 2)
Output: 6
Explanation: Lamps 2 and 6 are dark, and one block of 2 cannot reach both of them. Repairing lamps 2 and 3 makes the street "LLLLLLDLL", so lamps 0 to 5 are lit.
Input: longestLitStretch(lamps = "DDLDD", blockSize = 5)
Output: 5
Explanation: The block covers the whole street, so all 5 lamps are lit.