Amazon 'Music Playlist (OOD)' Interview Question
The "Music Playlist (OOD)" is an Amazon object-oriented design (OOD) interview problem focused on implementing a playlist system for a user's most recently played songs on Amazon Music. It emphasizes backend data structures, system design principles, and efficient operations, with tags like Backend, OOD, web, machine_learning (potentially for future extensions like recommendations), and System Design.[3]
Design and implement a playlist that maintains a user's most recently played songs on Amazon Music. The playlist should support efficient operations to add new songs and retrieve existing ones, ensuring no duplicates and preserving recent play order (e.g., like a queue or LRU cache). Key requirements include handling song searches and additions scalably for real-time web usage.[3]
Songs are typically represented with attributes like ID, title, artist, and duration. The design must use appropriate OOP principles (classes, interfaces) and data structures like HashMap for lookups combined with DoublyLinkedList for order.[3]
No formal input/output test cases are provided in sources, as this is an OOD problem emphasizing class design over algorithmic coding. Example usage (pseudocode):
` Playlist playlist = new Playlist(maxSize); // e.g., maxSize=100 for recent songs
// addSong examples playlist.addSong(new Song("123", "Song A", "Artist X")); // Adds to playlist playlist.addSong(new Song("123", "Song A", "Artist X")); // Updates recency, no duplicate
// getSong examples Song song1 = playlist.getSong("123"); // Returns Song A (most recent) Song song2 = playlist.getSong("456"); // Returns null (not found) `
Expected behavior mimics LRU (Least Recently Used) cache: oldest songs evict on capacity overflow.[3]
This matches Amazon SDE interviews for new grads (2021 reports), testing OOP, data structures, and trade-offs like HashMap + DLL vs. LinkedHashMap.[10][3]