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
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Late January, 2025
Intern
Longest ideal subsequence
Hello Interview Premium
Your account is free and you can post anonymously if you choose.