MEDIUMasked at 12 companies

Longest Common Subsequence

A medium-tier problem at 58% community acceptance, tagged with String, Dynamic Programming. Reported in interviews at BP and 11 others.

Founder's read

Longest Common Subsequence is a classic DP problem that shows up at companies like ByteDance, DoorDash, and Citadel. It's medium difficulty with a 58% acceptance rate, so it's not a gimme but it's not a curveball either. The trap is thinking this is easy because the name is obvious. Most candidates know the brute force (check all subsequences) or vaguely remember "2D array" but blank on the actual recurrence or how to reconstruct the answer. If you hit this on a live assessment and can't piece together the DP transition, StealthCoder solves it invisibly while you stay focused on explaining your approach to the proctor.

Companies asking
12
Difficulty
MEDIUM
Acceptance
58%

Companies that ask "Longest Common Subsequence"

If this hits your live OA

Longest Common Subsequence is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.

Get StealthCoder
What this means

The trick here is recognizing that this is a comparison problem, not a search problem. You need a 2D DP table where dp[i][j] represents the length of the LCS between the first i characters of string one and the first j characters of string two. The recurrence is simple: if characters match, take the diagonal value plus one. If they don't match, take the max of the value above or to the left. Most candidates get stuck because they either try to build the full DP table and then can't backtrack to find the actual subsequence, or they overthink the base cases. The reconstruction step (backtracking from dp[m][n]) trips people up more than the table itself. String and Dynamic Programming are both core to this one, and that intersection is exactly what makes it a filter question at companies running serious OAs. If you've drilled this pattern before, great. If not and you blank during the assessment, StealthCoder delivers a working solution in seconds.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Longest Common Subsequence recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Longest Common Subsequence interview FAQ

Is Longest Common Subsequence still asked as much as it used to be?+

Yes, it appears in active recruiting loops at 10+ companies across finance, cloud, and tech. ByteDance, DoorDash, and Citadel have all asked it recently. It's not trendy, it's standard. If you're interviewing at FAANG-adjacent or fintech shops, budget prep time for this one.

What's the actual trick that makes people fail this?+

Confusing LCS with longest matching substring. If the strings are 'abc' and 'aec', the LCS is 'ac' (length 2), not a continuous block. The DP recurrence works only if you grasp that you're matching characters anywhere in the string, not a contiguous window.

How does this relate to real interview DP patterns?+

LCS is a gateway to understanding 2D DP state machines. Once you can do this, edit distance and pattern matching become easier. It's foundational. Companies use it to filter candidates who understand memoization and state transitions versus those who just memorize solutions.

What languages does this problem assume you can code in?+

The problem itself doesn't mandate a language. Any language that supports 2D arrays and string indexing works. Python, Java, C++ are all fine. Don't second-guess your language choice. The algorithmic thinking is what's being tested.

If I blank on the backtracking step during the OA, can I still pass?+

Partly. If you can build the DP table correctly and explain the recurrence, you'll get partial credit. But most interviewers expect you to reconstruct the actual LCS string, not just the length. That's where having a safety net like StealthCoder matters if you freeze.

Want the actual problem statement? View "Longest Common Subsequence" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.