Leetcode - Count of Smaller Numbers After Self (Python)

preview_player
Показать описание
June 2021 Leetcode Challenge
Leetcode - Count of Smaller Numbers After Self #315
Difficulty: Hard

BIT Explaination:

SortedList Documentation:
Рекомендации по теме
Комментарии
Автор

Bro even the first solution is amazing. At times I just hold my head and say HOW!!!

CEOofTheHood
Автор

thanks for introduction to the new lib in python, seems like they are never ending for me :) what's the space and time complexity of both solutions ?

vgsuresh
Автор

First solution is not correct because it is n**2 not nlogn
Adding element to sorted list is not logn it is actually O(n) it slides the whole array

hikmetdemir
Автор

I totally forgot about the sortedlist class in python! It's used so rarely. I swear this is like the fifth Fenwick tree problem this month....

janmichaelaustria
Автор

HOW DO YOU COME UP WITH THESE GENIUS SOLUTIONS? I was in the same thought process as you up until the "heap won't work" hahahaha

andrewlee
Автор

ans=bisect_left(s, n) should work??
why are you including SortedList.bisect_left(s, n) ??

SouravKumar-tcql
welcome to shbcf.ru