Reported August 2026
TikToksliding window

Count Case-Insensitive Triplets

Reported by candidates from TikTok's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live TikTok OA. Under 2s to a working solution.
Founder's read

The detail that matters in this TikTok question from August 2026 is the word "consecutive." You're not picking any three characters from the string. You're counting windows of length 3 where the first and last letters match once case is ignored. So "aXA" counts as one. An empty string counts as zero. It's a string scan, and it's about as friendly as OA problems get. If your head goes blank under the timer, StealthCoder runs invisibly on screen share and can hand you the loop as a safety net. Most people won't need it here.

The problem

Given a string text consisting of uppercase and lowercase English letters, count all triplets of consecutive characters for which the first and last characters are the same when compared case-insensitively.
Note: You are not expected to provide the most optimal solution, but a solution with time complexity no worse than O(text.length^2) will fit within the execution time limit.

Function
solution(text: String) → int

Examples
Example 1
text = "aXA"
return = 1
The only triplet is "aXA". Its first and last characters are equal when compared case-insensitively, so the answer is 1.
Example 2
text = ""
return = 0
An empty string has no triplet of consecutive characters, so the answer is 0.

Constraints
text contains only uppercase and lowercase English letters.
text may be empty.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that consecutive triplets are just windows of size 3. Loop i from 0 to n-3, lowercase text[i] and text[i+2], and increment a counter when they match. The middle character never matters. That's O(n) time and O(1) space, which beats the O(n^2) ceiling the statement mentions, so don't overthink it. The common pitfalls are off-by-one bounds, which crash on short strings, and forgetting the empty string case. If n is under 3, return 0 before the loop. Another slip is comparing raw characters, so 'a' and 'A' fail to match. Normalize case first with lower() or a char-code check. The pattern is a fixed-width sliding window. If you freeze during the live OA, StealthCoder is the hedge that reads the prompt and gives you the loop. Keep your own bounds check anyway.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Count Case-Insensitive Triplets 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass TikTok's OA.

TikTok reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Case-Insensitive Triplets FAQ

How hard is the Count Case-Insensitive Triplets question really?+

Easy. It's a single pass over the string with a fixed window of three characters. The only real risks are bounds errors and forgetting to normalize case. If you can write a for loop and compare two characters, you can finish this in a few minutes.

What's the trick to solving it?+

Treat every index i as the start of a window covering i, i+1, i+2. Only compare text[i] with text[i+2], lowercased. The middle character is irrelevant. Count matches and return the total. No hash map or nested loops needed.

Do I need an O(n^2) solution because the statement mentions it?+

No. The note says O(n^2) is acceptable, but the linear scan is simpler and faster. Writing the O(n) version is also less code, so there's less room for bugs. Don't build anything fancier than one loop.

What edge cases should I test?+

Test the empty string, strings of length 1 and 2, which should all return 0, and the exact example "aXA" returning 1. Also try overlapping matches like "aaaa", which has two valid triplets, and mixed case like "AbA" or "aBA" to confirm case folding works.

How do I prepare for this in 48 hours?+

Write the sliding window loop from memory twice, in your OA language. Practice case-insensitive comparison and the short-string guard. Then skim other fixed-window string problems so the pattern feels automatic. This one rewards clean basics over deep prep.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with TikTok.

OA at TikTok?
Invisible during screen share
Get it