Reveal Cards in Increasing Order
Updated
Problem statement
A deck contains cards with distinct positive integer values. Choose its starting order so the following process reveals the values in strictly increasing order:
- Reveal and remove the top card.
- If any cards remain, move the new top card to the bottom.
- Repeat until the deck is empty.
Return the starting deck as an array, with its top card first. Use every given card exactly once.
Function
deckRevealedIncreasing(deck: int[]) → int[]Examples
Example 1
deck = [4,1,3,2]return = [1,3,2,4]The reveal sequence is 1, 2, 3, 4 after moving each next top card to the bottom.
Example 2
deck = [5,12,7]return = [5,12,7]Reveal 5, move 12 below 7, then reveal 7 and 12.
Example 3
deck = [8,2]return = [2,8]Reveal 2, then reveal the remaining card 8.
Constraints
1 <= deck.length <= 1000.1 <= deck[i] <= 10^6.- All card values are distinct.
More NVIDIA Phone Screen questions
- Network Layer Execution OrderPHONE SCREEN · Seen Nov 2026
- Paged KV Cache AccessPHONE SCREEN · Seen Nov 2026
- Sliding Window Attention over a KV CachePHONE SCREEN · Seen Nov 2026
- Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
- Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
- Filter Paginated Medical RecordsPHONE SCREEN · Seen Oct 2026
- Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
- Parallel String Counts with a Custom Hash TablePHONE SCREEN · Seen Oct 2026
- Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
- Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026
Similar questions at other companies
- Dynamic Longest-Waiting Unique Task QueriesAmazon · PHONE SCREEN
- Bus Station Seat AllotmentInMobi · PHONE SCREENInMobi interview questions
- Top Ten Largest FilesGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Valid Triangle NumberBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Implement QuicksortByteDance · PHONE SCREENByteDance interview questions
- Rank Word-Translation Hints from Sentence TranslationsDuolingo · PHONE SCREEN · ONSITE INTERVIEWDuolingo interview questions
- Fair Capped Money DistributionGusto · PHONE SCREEN · ONSITE INTERVIEWGusto interview questions
- Merge IntervalsApple · OA · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
- Merge Sorted Squares of Two ArraysWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
- Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions