Reported September 2026
TikTokgreedy

Catch Fish with Reusable Baits

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 September 2026 dresses a simple simulation up in fishing gear. Strip the story and it's a sorted-array matching problem with a cap of three uses per bait. Sort both arrays, walk the baits from largest to smallest, and take the biggest fish each one can legally catch. The constraints go up to 10^5, so brute force dies. If you blank under the clock, StealthCoder runs invisibly during the live assessment and gives you the working solution as a safety net. Here's what the problem really reduces to and where people slip.

The problem

You are given two arrays of positive integers, fish and baits. Each value in fish is a fish size, and each value in baits is the size of one bait.
A bait can catch a fish only when the bait is strictly smaller than that fish.
A caught fish is removed and cannot be caught again.
Each bait can be used at most 3 times.
Process the baits from largest to smallest. For each bait, repeatedly catch the largest remaining fish that it can catch. Move to the next bait after the current bait has been used three times or when it cannot catch any remaining fish.
Return the total number of caught fish after every bait has been processed.

Function
countCaughtFish(fish: int[], baits: int[]) → int

Examples
Example 1
fish = [1,2,3]
baits = [1]
return = 2
The bait of size 1 catches fish of sizes 3 and 2. It cannot catch the remaining fish of size 1, so the result is 2.
Example 2
fish = [2,2,3,4]
baits = [1]
return = 3
The only bait is smaller than every fish, but it can be used only three times. It catches fish of sizes 4, 3, and 2.
Example 3
fish = [1,4,3,2]
baits = [1,1]
return = 3
The first bait catches fish of sizes 4, 3, and 2. The only remaining fish has size 1, so the second bait cannot catch it.

Constraints
1 ≤ fish.length ≤ 10^5
1 ≤ baits.length ≤ 10^5
1 ≤ fish[i] ≤ 10^9
1 ≤ baits[i] ≤ 10^9

Reported by candidates. Source: FastPrep

Pattern and pitfall

Sort fish ascending and baits descending. The largest bait is the most capable, and it gets first pick of the largest fish it can catch. Keep a pointer at the end of the fish array. For each bait, loop up to 3 times: if the fish at the pointer is strictly greater than the bait, count it and move the pointer left. If not, the bait is stuck, because every smaller fish is also too small, so you can move on. Wait, check this carefully. The largest remaining fish is the easiest one for a bait to catch. If that one fails, nothing else works for that bait. Common pitfalls are using less-than-or-equal instead of strictly smaller, forgetting the 3-use cap, and rescanning the array for every bait, which turns it quadratic. Total cost is O(n log n + m log m) from the sorts. StealthCoder is your hedge if the off-by-one logic slips live.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Catch Fish with Reusable Baits 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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Catch Fish with Reusable Baits FAQ

What's the trick in Catch Fish with Reusable Baits?+

Sort both arrays and use a single pointer on the largest remaining fish. Each bait, from largest to smallest, takes up to three fish from the top. If the biggest remaining fish isn't larger than the bait, no other fish will be either, so you stop that bait.

How hard is this TikTok OA question really?+

Easy to medium. The logic is short once you see it. The difficulty is reading the rules carefully: strict inequality, a cap of three uses, and the largest-to-smallest processing order. Most failures come from misreading, not from the algorithm.

Why not just simulate with a list and remove fish?+

With up to 10^5 fish and 10^5 baits, removing from or scanning a list for every catch is too slow. Sorting once and moving a pointer inward gives you the same result in near-linear time after the sort.

What edge cases should I test?+

Test a bait equal to the fish size, since it must catch nothing. Test one bait with many fish, so the cap of 3 matters. Test more baits than fish, and values up to 10^9 to confirm nothing overflows in your language.

How do I prepare for this in 48 hours?+

Write this one from scratch twice. Then do a few sort-plus-pointer greedy problems so the pattern feels automatic. Focus on reading constraints and spotting strict versus non-strict comparisons, because that's where this question punishes you.

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