Match Songs with Repeatable Animations
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 fancier than it is. Strip the song and animation theme and you're left with string parsing plus a first-match divisibility check. For each song, walk the animations in order and take the first whose length divides the song length. That's it. If you've got an OA invite for Capital One this week, expect this kind of problem: simple logic wrapped in a story, where the only real risk is sloppy parsing. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but this one is easy enough to write cold.
The problem
You are given arrays songs and animations. Every string has the form name:length, where length is a positive integer duration. An animation is compatible with a song when its duration does not exceed the song duration and divides the song duration exactly. In that case, repeating the animation songDuration / animationDuration times fills the song. For each song, scan animations from left to right and choose the first compatible animation. Return one string per song in the form animationName:repeatCount. Function matchSongsWithAnimations(songs: String[], animations: String[]) → String[] Examples Example 1 songs = ["notion:180","voyage:185","sample:180"] animations = ["circles:360","squares:180","lines:37"] return = ["squares:1","lines:5","squares:1"] circles:360 is longer than every song. squares:180 is the first compatible animation for both 180-second songs and repeats once. For voyage:185, lines:37 is the first compatible animation and repeats 5 times. Example 2 songs = ["loop:120"] animations = ["pulse:30","wave:40"] return = ["pulse:4"] Both animations divide 120, so input order chooses pulse:30. It repeats 4 times. Constraints 1 <= songs.length <= 100 1 <= animations.length <= 100 Every entry contains exactly one colon, a nonempty name without a colon, and a duration from 1 through 10^5. Every song has at least one compatible animation.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The whole problem reduces to a nested loop. Split each string on the colon, convert the duration to an integer, then for each song iterate animations left to right. The first animation where animDur <= songDur and songDur % animDur == 0 wins. Output name:(songDur / animDur) using integer division. With at most 100 songs and 100 animations, brute force is 10^4 checks, so don't optimize. The pitfalls are small. Don't pick the best match, pick the first one. Don't forget to break after finding it. Parse animations once up front instead of re-splitting inside the loop. Note that divisibility already implies the length check, since a positive divisor larger than the number can't divide it evenly. Names can't contain colons, so a plain split works. If you freeze on the format of the output string, StealthCoder can cover you during the live OA, but the logic here is short.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Match Songs with Repeatable Animations 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 would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Capital One's OA.
Capital One reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Match Songs with Repeatable Animations FAQ
How hard is the Capital One Match Songs with Repeatable Animations problem really?+
Easy. It's string parsing plus a nested loop with a modulo check. Constraints cap both arrays at 100, so brute force passes. The only way to fail is misreading the rule or botching the output format.
What's the trick to this problem?+
There isn't a clever one. For each song, scan animations in input order and return the first where songDuration % animationDuration == 0. First match wins, not best match. Example 2 shows this: both 30 and 40 divide 120, but pulse comes first.
Do I need to check that the animation is not longer than the song?+
Not separately. Durations are positive, so a longer animation can never divide a shorter song evenly. The modulo check covers it. Adding an explicit comparison is harmless if it makes you feel safer, but it's redundant.
How should I parse the name:length strings?+
Split on the colon, keep the name as a string and convert the second part to an int. Every entry has exactly one colon, so a simple split works. Parse the animations once before the loop so you don't repeat work for each song.
How do I prepare for this in 48 hours?+
Practice string splitting and nested-loop matching in your language of choice until the output formatting is automatic. Write this exact function once, test both examples, and check that integer division gives the repeat count. Then spend remaining time on other easy-to-medium array and string problems.