DEV Community

Somuya Khandelwal
Somuya Khandelwal

Posted on • Edited on

DAY 54 Hash Maps and Sets: Unlocking Efficiency

Hello Everyone!

On the fourth day of the eleventh week, the topics that were covered were Hash Map/Set Problems since the main and maybe the only priority here is efficiency. These tasks underlined the efficiency of dealing with data structures, of asking questions to the underlying data, of transforming what potentially could have been complex operations into rather simple and refined uses. This I found was like looking for clues and assembling it to solve puzzles.


Au joué quoi à搞23899830了駅】#### **How the Day Went

  1. Find the Difference of Two Arrays **Easy Difficulty

    • Return two lists: to construct the arrays of one such type that contains elements which are not present in the first array and one that contains only elements that are not in the second array.
    • The Strategy: Primarily utilized two sets to preserve separate elements out of two arrays. The differences were determined by set based operations such set difference (difference), and set intersection.
    • The Fun Part: Besides, seeing the sets coming together and then figuring out elements that need to be separated was like solving jigsaw of two partially overlapping puzzles.
  2. *Unique Number of Occurrences Based on The Level of Difficulty : Easy *

    Figure out whether all the elements in the array have a different frequency.

    • The Strategy: saved _counted the frequency of each element using the hash map. H: searched whether the numbers set in the hash map were distinct with hashmap’s value (frequencies) utilizing hash set.
    • The Fun Part: Avoiding the scenario where the frequencies overlapped felt like keeping a stock accurate.

things that made today special

  1. Efficiency through Hashing:

    These two problems showcased the ability of hash maps and sets in faster and efficient control of data.

  2. Clean and Modular Logic:

    Some of the tasks, which have been solved, like Unique Number of Occurrences, illustrated the ways to divide a given problem into a set of more manageable and well-defined parts that guarantee both clear understanding of the problem and its proper solution.

  3. Practical Problem-Solving:

    Recall that the utilization of hash based structures, resembles the approach to working with datasets or fine tuning a database query.


Key Takeaways

  • Set Operations Simplify Differences:

    • Problems like Find the Difference of Two Arrays show how set operations reduce the complexity of comparing large datasets.
  • Hash Maps Are Invaluable:

    • Counting elements and verifying uniqueness, as in Unique Number of Occurrences, reinforces the importance of hash maps in competitive programming.
  • Modular Thinking Enhances Clarity:

    • Dividing tasks into distinct steps (e.g., counting, checking uniqueness) ensures solutions are easier to implement and debug.

Reflections

Working on the problem Find the Difference of Two Arrays proved to me how set operations could simplify comparative work, while Unique Number of Occurrences gauged my ability to handle and query hash-based structures efficiently. These challenges highlighted the importance of hashing for solving real-life problems efficiently.


What’s Next?

On Monday, I’ll wrap up Week 11 with more Hash Map/Set Problems, tackling Determine if Two Strings Are Close and Equal Row and Column Pairs. Those will prove challenging with respect to my skills of managing relationships and symmetry in datasets.

Thanks for staying tuned! Here’s to solving, learning, and growing together!

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay