Playlist With No Same Artist in a Row
Updated
Problem statement
You have a playlist of n songs. Song i is by the artist artists[i]. Arrange all n songs into a play order so that no two songs in a row are by the same artist.
The problem statement continues
ProExamples
Example 1
artists = ["a","a","a","b","b","c"]return = [0,3,1,4,2,5]Song 0 (a) goes first. Song 1 is also by a, so the next smallest choice is song 3 (b). Then come song 1 (a), song 4 (b), song 2 (a) and song 5 (c). The answer is [0,3,1,4,2,5].
FastPrep Pro
Reported in 1 Google interview this weekUnlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 2 more worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$8.25/month
$99 billed yearly — or $19 month-to-month. Cancel anytime.
Free plan — 2 of 2 free unlocks used this week
More Google Onsite Interview questions
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
- Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Minimize Distinct Item Types After RemovalsRoblox · OARoblox interview questions
- Rearrange a String So No Neighbors MatchThe D.E. Shaw Group · ONSITE INTERVIEWThe D.E. Shaw Group interview questions
- Reorganize a StringAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Longest-Match Tokenizer with Unknown SymbolsAnthropic · ONSITE INTERVIEWAnthropic interview questions
- Reduce Array Size to At Most HalfMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Nickname-Constrained GroupingZoox · ONSITE INTERVIEW
- Choose the Next Hidden-Word GuessFlexport · ONSITE INTERVIEWFlexport interview questions
- Best Poker Category with a JokerScale AI · PHONE SCREEN · ONSITE INTERVIEWScale AI interview questions
- Find All Zip Rummy MeldsZip · PHONE SCREEN · ONSITE INTERVIEWZip interview questions
- Markov Transition Counts and ProbabilitiesRetool · ONSITE INTERVIEWRetool interview questions
Google interview experiences
- Google L5 Security Engineer Domain Knowledge Round: 1 Experience
- Google Software Engineer Onsite Questions: 10 Experiences
- Google OA: What It Tests (2026)
- Google L4 SWE Phone Screen: 1 Experience
- Google ML Engineering Manager Onsite: 1 Experience
- Google Experienced SWE First Round and Onsite: 1 Experience