A display mechanism is built from several spinning reels arranged in a line, from left to right. Each reel has a number of distinct letters on its perimeter, and only one of them is visible at a time. The visible letter changes every second. Each reel may have a different number of letters.
You are given a String[] reels, where reels[k] represents the letters on the k-th reel.
At time 0, each reel shows the letter at index 0 from the corresponding element of reels. At every second, the visible letter changes from the letter at index i to the letter at index i+1. Since reels are circular, the first letter shows up again after the last one.
Return the first second when the text displayed is equal to requiredText, or -1 if this will never happen.
|