LeetCode 1128: Number of Equivalent Domino Pairs - Interview Prep Ep 18

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

Leetcode 1128. Number of Equivalent Domino Pairs

Solution explained:
1. We'll iterate through this entire array of pairs to find all possible equivalent pairs.
2. We can use a HashMap to help us memorize all the ones that we have already gone through to avoid repeated going through the same pairs for every other pair, this can help us optimize the time complexity from the brute force solution O(n^2) (nested for loop) down to O(n)
3. While building this hashmap, we could find all equivelant pairs in the same iteration, after this loop, we could just safely return the count as the result.

Coding interview made simple!

⭐ Support my channel and connect with me:

// TOOLS THAT I USE:

// MY FAVORITE BOOKS:

My ENTIRE Programming Equipment and Computer Science Bookshelf:

And make sure you subscribe to my channel!

Your comments/thoughts/questions/advice will be greatly appreciated!

#softwareengineering #leetcode #algorithms #coding #interview #SDE #SWE #SiliconValley #programming #datastructures
Рекомендации по теме
Комментарии
Автор

What question should I go through next? Any comments/questions would be appreciated! ❤️

FisherCoder
Автор

I think time complexity is nlogn . ordered map is implemented by red black tree

sahilnegi
Автор

why did you multiply with 10 can you explain me in comment section.

abhiram
join shbcf.ru