Amazon Coding Question - Insert Delete GetRandom O(1)
🎧 Join the community Discord: https://discord.gg/aVWsAaaCtT
💰 Support me on Patreon: https://www.patreon.com/michaelmuinos
🔗Follow me on LinkedIn: https://www.linkedin.com/in/michael-muinos
📂Follow me on Github: https://github.com/MichaelMuinos
Check out my interview prep platform for learning the patterns!
📢 Interview Prep Platform: https://algoswithmichael.com
For this video, I go over the popular coding interview problem "Insert Delete GetRandom O(1)" found on the LeetCode platform. This problem is asked at many tech companies including Amazon, Bloomberg, Facebook, Oracle, and Twitter. This coding question is a design problem that tests your knowledge of the arraylist and map data structures.
We have to implement three different functions: insert, remove, and get random. Insert will take a value and insert it inside of a data structure. Remove will take a value and remove it from the data structure. Get random will return a random element from our data structure where each element must have an equal probability of being chosen.
The time complexity of the optimal approach will be O(1) constant time since we are using a map to store the elements with their appropriate indices and only removing the last element in our arraylist. The space complexity will be linear where N is the number of entries we have in our map and list.
Видео Amazon Coding Question - Insert Delete GetRandom O(1) канала AlgosWithMichael
💰 Support me on Patreon: https://www.patreon.com/michaelmuinos
🔗Follow me on LinkedIn: https://www.linkedin.com/in/michael-muinos
📂Follow me on Github: https://github.com/MichaelMuinos
Check out my interview prep platform for learning the patterns!
📢 Interview Prep Platform: https://algoswithmichael.com
For this video, I go over the popular coding interview problem "Insert Delete GetRandom O(1)" found on the LeetCode platform. This problem is asked at many tech companies including Amazon, Bloomberg, Facebook, Oracle, and Twitter. This coding question is a design problem that tests your knowledge of the arraylist and map data structures.
We have to implement three different functions: insert, remove, and get random. Insert will take a value and insert it inside of a data structure. Remove will take a value and remove it from the data structure. Get random will return a random element from our data structure where each element must have an equal probability of being chosen.
The time complexity of the optimal approach will be O(1) constant time since we are using a map to store the elements with their appropriate indices and only removing the last element in our arraylist. The space complexity will be linear where N is the number of entries we have in our map and list.
Видео Amazon Coding Question - Insert Delete GetRandom O(1) канала AlgosWithMichael
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Facebook Coding Interview Question - First and Last Position in Sorted Array (LeetCode)Simplify Path - LeetCode 71 - Popular Meta Interview QuestionLyft Coding Interview Question - Asteroid CollisionTime Based Key Value Store | Netflix Coding Question | Binary SearchTechnical Interview Question - Max Area of Island [LeetCode]5 Tips to BEAT the LeetCode GrindThe Resume That Got Me A Fully Remote Job (Software Engineer Resume Tips)Interview With A Self Taught Software Engineer Making Over 6 FiguresTechnical Interview Question: Valid Anagram [LeetCode]Advice from a self-taught developer #selftaughtdeveloper #learntocode #techcareers5 Data Structures Explained MUST KNOW (for Software Engineers)A Google Engineer's Computer Science Degree (Projects, Homework, & Grades)Evaluate Reverse Polish Notation - LeetCode 150 - Stack Data StructureGoogle Coding Interview Question - Plus One [LeetCode]The Frustrating Truths About Coding InterviewsMinimum Path Sum | Dynamic Programming (LeetCode)Facebook Coding Interview Question - Average of Levels in Binary TreeSurrounded Regions | BFS & DFS | LeetCodeFACEBOOK CODING QUESTION - ADD STRINGS (LEETCODE)6 Pros of Working at a Startup (as a Software Engineer)Technical Interview Question - Reverse Integer [LeetCode]