Count Alternating Tile Groups
Reported by candidates from Capital One's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Capital One reported this one in September 2026, and it looks friendlier than it is. Count Alternating Tile Groups sounds like a circular array puzzle, but it reduces to one question: how long is each run of alternating tiles? If you've got an OA invite and 48 hours, this is the pattern to lock in. The circle is the only real trap. Get the wraparound right and the rest is a single pass. If you blank on the live assessment, StealthCoder is the invisible hedge sitting on your desktop, but you shouldn't need it once you see the shape.
The problem
A circular row of red and blue tiles is represented by tileColors. A value of 0 means red and a value of 1 means blue. Count how many groups of exactly size consecutive tiles have alternating colors, meaning every adjacent pair inside the group has different colors. The tiles form a circle, so the first and last elements of tileColors are adjacent. A solution with time complexity no worse than O(tileColors.length^2) fits within the execution limit. Function solution(tileColors: int[], size: int) → int Examples Example 1 tileColors = [0,1,0,1,1] size = 3 return = 3 The groups beginning at indices 0, 1, and 4 alternate. The other two groups contain adjacent blue tiles, so the result is 3. Constraints tileColors.length ≥ 1 Every element of tileColors is either 0 or 1. 1 ≤ size ≤ tileColors.length
Reported by candidates. Source: FastPrep
Pattern and pitfall
Here's the trick. A window of exactly size tiles alternates if every adjacent pair inside it differs. So mark each position i as good if tileColors[i] != tileColors[(i+1) % n]. A window starting at i is valid when the size-1 consecutive pairs starting at i are all good. That's a sliding window or a run-length count over the circular array. The brute force is O(n * size), which the stated O(n^2) allowance covers, so you can write it safely. The common pitfall is forgetting the wrap, so use modulo indexing. Also watch size = 1, where every start index counts and there are no pairs to check. Check your logic against the example: [0,1,0,1,1] with size 3 returns 3. If the live OA freezes your brain, StealthCoder can feed you the modulo version in real time, invisible to the proctor.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Count Alternating Tile Groups cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as alternating groups i. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Capital One's OA.
Capital One reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Count Alternating Tile Groups FAQ
What's the trick in Count Alternating Tile Groups?+
Turn it into adjacent-pair checks. A group of size k alternates if k-1 consecutive pairs all differ. Use modulo indexing so the last tile connects to the first, then count start positions where every pair in the window is a difference.
How hard is this Capital One OA question really?+
Easy to medium. The idea is simple, but the circular wraparound and edge cases like size 1 trip people up. The O(n^2) allowance means a brute-force window check passes, so you don't need the optimized version to get credit.
Do I need a sliding window or is brute force enough?+
Brute force is enough here since the stated limit allows O(n^2). For each start index, check size-1 pairs with modulo. If you want the faster route, track the current alternating run length over a doubled traversal and count valid windows.
What edge cases should I test?+
Test size = 1, where every start index counts. Test size equal to the array length, where the wrap pair matters. Test a single-element array, and an all-same-color array, which should return 0 for any size above 1.
How do I prepare for this in 48 hours?+
Write the modulo-indexed brute force from scratch, then the linear version. Run the example [0,1,0,1,1] with size 3 and confirm you get 3. Practice circular indexing on two or three similar array problems and you're covered.