New
ML System Design & SQL tracks just landed
See what's new
×
Question Bank
Pricing
Blog
Forum
HOT
JobRadar
NEW
Referral
Description
Solution
Discussion
Submissions
Ask AI
Question Bank
Snowflake
Coding Question
AI Insights
Quick Summary
Find the longest subsequence where at most k adjacent pairs have different values.
Subsequences must preserve the original relative order of elements.
Maximize length while strictly limiting value transitions between consecutive selected elements.
What This Tests
Dynamic programming state definition and transition logic
Optimizing space and time for sequence-based constraints
Using hash maps to track best outcomes per distinct value
Managing overlapping subproblems with limited transition budgets
Common Patterns
Dynamic Programming
Hashing
Collapse
Hint 1
Hint 2
What Interviewers May Ask Next
Ask AI Assistant
Ask AI Assistant
Ask me anything about this coding question!
Qwen
Qwen3.6-Flash
0/2000
Auto
Debug
Run
Submit
Test Cases
Input
Output
Expected