Reported July 2026
TikTokcounting

Uppercase-Lowercase Difference

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 TikTok OA reported in July 2026 looks like a warm-up, and that's exactly the trap. Uppercase-Lowercase Difference asks for one number: uppercase count minus lowercase count in a string. The edge case that breaks a naive solution is the sign. Subtract in the wrong order and "a" returns 1 instead of -1, and "CodeSignal" flips from -6 to 6. It's a counting problem, nothing fancier. If you blank under the timer, StealthCoder runs invisibly on screen as a safety net, so a simple problem doesn't cost you a rushed mistake.

The problem

In a typing-practice application, user input is represented by a string typedText containing uppercase and lowercase English letters.
Return the number of uppercase letters minus the number of lowercase letters in typedText.

Function
solution(typedText: String) → int

Examples
Example 1
typedText = "CodeSignal"
return = -6
There are 2 uppercase letters (C and S) and 8 lowercase letters, so the result is 2 - 8 = -6.
Example 2
typedText = "a"
return = -1
There are no uppercase letters and one lowercase letter, so the result is 0 - 1 = -1.

Constraints
typedText contains only uppercase and lowercase English letters.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that there's no trick. Walk the string once, add 1 for each uppercase letter and subtract 1 for each lowercase letter, then return the running total. That's O(n) time and O(1) space. You don't need two counters, though two is fine if it keeps you honest. The pitfall is direction. The answer is uppercase minus lowercase, so a lowercase-heavy string gives a negative number. Check it against both examples: "CodeSignal" gives 2 - 8 = -6, and "a" gives -1. The constraints say only English letters appear, so you don't need to handle digits or spaces. Use isupper and islower, or compare character ranges. Overthinking is the real risk here, like sorting or building a hash map you don't need. If you freeze on a problem this small during the live OA, StealthCoder gives you the answer to check against.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Uppercase-Lowercase Difference 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 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. 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.

Uppercase-Lowercase Difference FAQ

How hard is the TikTok Uppercase-Lowercase Difference problem really?+

It's easy. One pass through the string, one running total. The only thing that costs people points is subtracting in the wrong order. Test both examples before you submit and you're done in a few minutes.

What's the trick to this problem?+

There isn't one beyond the sign. Add 1 for each uppercase letter, subtract 1 for each lowercase letter. Return the total. Uppercase minus lowercase means lowercase-heavy input gives a negative result, as in the "a" example returning -1.

What edge cases should I test?+

Test a single lowercase letter, a single uppercase letter, and an all-uppercase string. Also try a balanced string like "aA", which should return 0. The constraints say only English letters appear, so you don't need to handle other characters.

What's the time and space complexity?+

Time is O(n), since you visit each character once. Space is O(1), because you only keep a running integer. Nothing faster exists, since you have to read every character at least once.

How do I prepare for this in 48 hours?+

Don't over-prepare for this one. Write it once in your language, using its uppercase and lowercase checks, and run both examples. Then spend your remaining time on the harder questions an OA like this might pair it with, such as strings and hash maps.

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