COUNT OF SMALLER NUMBERS AFTER SELF | LEETCODE 315 | PYTHON BINARY SEARCH SOLUTION

  Рет қаралды 5,177

Cracking FAANG

Cracking FAANG

Күн бұрын

Пікірлер: 18
@yg1095
@yg1095 9 ай бұрын
Smartest and cleanest solution I have seen for this question. Amazing job!
@JohnIdlewood
@JohnIdlewood Жыл бұрын
The salt is inserting into the middle of the array. Inserting into the middle of the array is O(n) because you have to copy it. So the result complexity is still O(n^2)
@crackfaang
@crackfaang Жыл бұрын
Yea it’s not possible to optimal solve it without a sorted array data structure that can maintain the sorted order and also insert in O(1) time. Other languages have it but Python unfortunately doesn’t out of the box
@dojoPojo
@dojoPojo Жыл бұрын
@@crackfaang Thanks a lot ! for this c++ code it is giving TLE for 3 test cases but that's okay public: vector countSmaller(vector& nums) { multiset sorted; vector ans(nums.size()); for (int i = nums.size() - 1; i >= 0; i--) { int curr = nums[i]; auto it = sorted.lower_bound(curr); ans[i] = distance(sorted.begin(), it); sorted.insert(it, curr); } return ans; } };
@meylyssa3666
@meylyssa3666 4 ай бұрын
it's so simple as you explained it! Clean and ah so smart, thank you a lot!
@kalyanvejalla
@kalyanvejalla Ай бұрын
such a fantastic video!
@vivek.tiwary
@vivek.tiwary Ай бұрын
We can avoid reversing operation & directly assign to result[r] = index;
@mohammadfaizanazim8865
@mohammadfaizanazim8865 9 ай бұрын
loved the haha at 1:05 :XD
@Aryan-ku6ji
@Aryan-ku6ji 2 ай бұрын
the only issue here is that we are using sorted containers which is not a part of default python package. OA might not accept this. Also its not available in languages like C++ where these are just AVL ..so the indexing takes O(n) time. Here its a chunk like data structure which not only inserts, deletes in log n time but indexes in O(1) time... interviewer might ask you to implement this and you get caught in rabbithole🤣..Better to use merge sort here
@andriidanylov9453
@andriidanylov9453 11 ай бұрын
Wow.Shortest solution
@billy9808
@billy9808 2 жыл бұрын
Bro, I just want to say thank you for the help, I watch your videos every day. I got demotivated since most companies were laying off or hiring freeze, but your consistent uploads kept me on my feet. My first FAANG paycheque is coming your way
@crackfaang
@crackfaang 2 жыл бұрын
Thanks for the kind words my friend. I know it’s tough given the current job market but this is actually the best time to Leetcode because there’s really zero time pressure on you and you can take your time to learn everything properly without worrying about a deadline. Make the most of the time since most people will just stop entirely. When hiring resumes you’ll be ready to go while everyone else starting up again
@johnj171
@johnj171 4 ай бұрын
Hiii Now hey You i have subscribes and I am loving you content and your little intimidation too don't so stop now!
@ziqinwu2337
@ziqinwu2337 7 ай бұрын
Thank you!
@billy9808
@billy9808 2 жыл бұрын
10K+ Subscribers by next year Feb💯
@crackfaang
@crackfaang 2 жыл бұрын
That’s the goal. I have some big plans for the channel next year… hoping for 100k by the end of next December!
@UtkarshKulkarni-v5o
@UtkarshKulkarni-v5o Ай бұрын
bro code!
@crackfaang
@crackfaang Ай бұрын
I sound nothing like that 😂
SUBARRAY SUMS DIVISIBLE BY K | LEETCODE 974 | PYTHON SOLUTION
16:24
Cracking FAANG
Рет қаралды 3,1 М.
How many people are in the changing room? #devil #lilith #funny #shorts
00:39
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 199 МЛН
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 695 М.
MEETING ROOMS III | LEETCODE # 2402 | PYTHON HEAP SOLUTION
18:40
Cracking FAANG
Рет қаралды 6 М.
MINIMUM AREA RECTANGLE | GOOGLE INTERVIEW QUESTION | PYTHON SOLUTION
14:16
RACE CAR | LEETCODE # 818 | PYTHON BFS SOLUTION
15:40
Cracking FAANG
Рет қаралды 11 М.
When Optimisations Work, But for the Wrong Reasons
22:19
SimonDev
Рет қаралды 1,1 МЛН
Lucky Numbers in a Matrix - Leetcode 1380 - Python
16:21
NeetCodeIO
Рет қаралды 8 М.
How many people are in the changing room? #devil #lilith #funny #shorts
00:39