Search
⌘K

Leetcode 2370. Longest Ideal Subsequence

Given a string s and integer k, find the longest subsequence where the absolute difference between every two adjacent letters' positions in the alphabet is ≤ k — essentially a variant of longest subsequence solved by dynamic programming over the 26 letters, maintaining for each letter the best length of an ideal subsequence ending there and updating from letters within ±k.

Asked at:

Microsoft

Microsoft


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late January, 2025

Microsoft

Microsoft

Intern

Longest ideal subsequence

Comments

Your account is free and you can post anonymously if you choose.