New
ML System Design & SQL tracks just landed
See what's new
×
Question Bank
Pricing
Blog
Forum
HOT
Referral
Description
Solution
Discussion
Submissions
Ask AI
Question Bank
Coding Question
AI Insights
Quick Summary
Replace all instances of one value with another to group identical numbers together.
Minimize operations until every distinct value occupies a single contiguous segment.
Leverage connectivity logic to determine how many merges are required.
What This Tests
Graph connectivity and component merging
Disjoint Set Union data structure application
Array preprocessing and interval analysis
Deriving optimal operation counts from connected components
Common Patterns
Union Find
Hashing
Collapse
Hint 1
Hint 2
Hint 3
What Interviewers May Ask Next
Accepted
47
/90
Acceptance Rate
52.2%
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
arr =
Output
Expected