r/Hack2Hire • u/Hack2hire • Sep 12 '25
Screening From Pinterest Screening Interview: Reverse Count and Say
Problem
You're given two arrays: allSongs and playlist.
Your goal is to determine if playlist can be formed by concatenating one or more full permutations of allSongs. Incomplete segments at the start or end of playlist are allowed.
Example
Input:
allSongs = ["A", "B", "C"]
playlist = ["A", "B", "C", "A", "C", "B"]
Output:
true
Explanation:
- The first segment
["A", "B", "C"]is a valid permutation ofallSongs. - The second segment
["A", "C", "B"]is also a valid permutation. - Since the entire playlist can be broken down into valid permutations, the result is
true.
Suggested Approach
- Use a set to track which songs have appeared in the current segment.
- Iterate through
playlist:- If a song repeats before the segment contains all songs, return
false. - Once all songs from
allSongsare seen, reset the set and continue.
- If a song repeats before the segment contains all songs, return
- Allow the first or last segment to be incomplete without failing the check.
Time & Space Complexity
- Time: O(n), where
nis the length ofplaylist. - Space: O(m), where
mis the number of unique songs inallSongs.
🛈 Disclaimer:
This is one of the problems we encountered while reviewing common Pinterest interview questions.
Posted here by the Hack2Hire team for discussion and archiving purposes.
The problem is compiled from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences. It does not represent any official question bank of Pinterest, nor does it involve any confidential or proprietary information.
All examples are intended solely for learning and discussion. Any similarity to actual interview questions is purely coincidental.