COUNT UNHAPPY FRIENDS (Leetcode) - Code & Whiteboard
Автор: babybear4812
Загружено: 2021-02-04
Просмотров: 4051
Описание:
A tricky Bloomberg favourite! Thankfully, the solution itself is quite succinct :)
Time Complexity: O(n^2). For each of the n people, we will walk through (up to) n-1 entries in their preferences. Therefore, n * (n-1) approaches O(n^2).
Space Complexity: O(n^2). We will have n entries in the dictionary we create, and each one of those can have (up to) n-1 entries in the set. Therefore, n * (n-1) approaches O(n^2).
Let me know if you have any questions below! :)
https://leetcode.com/problems/count-u...
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Let's connect on LinkedIn!
/ aleksmitrovic
Follow me on Medium!
/ mitrovic.aleksandar
Questions or suggestions for new videos? Email me!
[email protected]
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: