LeetCode 706: ✅ Design HashMap || using array in C++

preview_player
Показать описание

🗺️ Welcome to our custom map adventure! In this scenario, we're creating our own map without using the built-in map. 🚀

📦 Inside our magical class called MyHashMap, we have a special private array called mp that stores our key-value pairs. 💫

🏁 To start our map, we use the constructor MyHashMap(). It sets all elements of the mp array to -1, indicating empty slots for now. 🧹

🖊️ When we want to add a key-value pair, we use the put(int key, int value) method. It assigns the provided value to the mp array at the index corresponding to the key. 📝

🔎 To find treasures in our map, we have the get(int key) method. It retrieves the value from the mp array based on the key, and voila! 🎁

❌ When we want to remove a key-value pair, we simply use the remove(int key) method. It sets the value in the mp array to -1, waving goodbye to that entry. 🌟

That's it! With our custom map, we can store, retrieve, and remove key-value pairs on our own adventure. Happy mapping!
#leetcode , #CodingChallenge, #CPlusPlus, #Algorithm, #DataStructures, #StringManipulation, #EasySolution, #Efficiency, #SpaceOptimization, #ProblemSolving, #Tutorial, #CodeWalkthrough, #ProgrammingTips, #SoftwareEngineering, #InterviewPreparation
00:00 Introduction
01:13 Examples
02:13 Approach
05:48 Animation
Рекомендации по теме
join shbcf.ru