Loading
Loading
A tiling machine lays coloured tiles in a row. You may lift and repaint at most k tiles.
Return the length of the longest run of a single colour achievable after repainting at most k tiles.
tiles = "AABABBA", k = 1[AABA]BBA3 A's, 1 B → repaint 1 → length 4AAB[ABBA]3 B's, 1 A → repaint 1 → length 44Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(n) time · O(alphabet) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
Repaint one tile to get four in a row.
Example 2
Repaint both of one colour.
Example 3