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
Uber
Coding Question
AI Insights
Quick Summary
Determine for each k from 1 to n whether the values 1 through k occupy a contiguous segment in the permutation.
Output a binary array where each entry indicates if the corresponding prefix set forms a valid contiguous subarray.
The large constraint (up to 10^5) demands an O(n) time solution rather than brute-force subarray checks.
What This Tests
Index mapping and constant-time lookups
Contiguous range validation via span analysis
Iterative state tracking with min/max boundaries
Algorithmic efficiency under tight constraints
Common Patterns
Hashing
Greedy
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