NeetCode #737LC-2370Medium2-D Dynamic Programming
← Back to All Problems#737 · #2370 · Longest Ideal Subsequence(最长理想子序列)
📌 Problem Statement & Constraints
Given a lowercase string
s and an integer k, a subsequence is ideal if the alphabet distance between every two consecutive chosen characters is at most k. Return the length of the longest ideal subsequence. Constraints: 1 <= s.length <= 10^5, 0 <= k <= 25.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!