← All problemsSign in

Longest Common Subsequence

CSESDynamic ProgrammingOpen on judge ↗

Given two arrays of integers, find their longest common subsequence. A subsequence is a sequence of array elements from left to right that can contain gaps. A common subsequence is a subsequence that appears in both arrays. Input The first line has two integers n and m: the sizes of the arrays. The second line has n integers a_1,a_2,\dots,a_n: the contents of the first array. The third line h

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start