Тёмный
Greg Hogg
Greg Hogg
Greg Hogg
Подписаться
Welcome to the channel! I make videos about Data Science and Coding Interview Preparation. I am the CEO of MLNOW.ai and owner of AlgoMap.io and its associated coding bootcamp. Email me at greg.hogg1@outlook.com 😊
4Sum - Leetcode 18 - Two Pointers (Python)
4:05
2 месяца назад
Комментарии
@ggwp8618
@ggwp8618 Час назад
This can be easily done using dictionaries or hash maps in Js?
@SeanKearney-g7d
@SeanKearney-g7d Час назад
god dam you killed this Greg
@SeanKearney-g7d
@SeanKearney-g7d Час назад
well done
@yvettcodes
@yvettcodes 2 часа назад
This was extremely helpful, thanks for posting!
@יאיר-נ8י
@יאיר-נ8י 2 часа назад
oh nice I am a beginer and I had a problem similar to search if a num is prime the most efficency plan I had in mind that you want to get n/2 and n/3 and etc until n/(squared n)-1 if it is equal an int and not float its not prime else its prime
@יאיר-נ8י
@יאיר-נ8י 2 часа назад
basicly O(squared(n))
@Papa-Murphy
@Papa-Murphy 3 часа назад
Effectively the same answer but with cacheing
@SaPpHiRe051918
@SaPpHiRe051918 4 часа назад
Subbed. Great explanation. Also base condition could be if (open==n && closed==n) then append.
@pianolessonswithbless879
@pianolessonswithbless879 4 часа назад
You said youve covered videos om DFS but I went through your playlist and didn't see it, please can you send me the link
@wanzhaocheng8973
@wanzhaocheng8973 5 часов назад
love how you showed all three approaches in the code! really helped me understand the essence of DP solution
@vuk5001
@vuk5001 5 часов назад
Yes yes faang, slavery, dont work, be your own boss
@kylehiggins7736
@kylehiggins7736 6 часов назад
I’m curious as to why you make this part of a class, can’t it exist as its own function?
@teostorm1
@teostorm1 6 часов назад
To conceptualize this, I tried flipping my notebook without rotating it. In every case this worked.
@teostorm1
@teostorm1 7 часов назад
I feel like vertical reflection would make more sense haha.
@jaskiratsingh3302
@jaskiratsingh3302 7 часов назад
Well,I used combination
@mcspamzockt1807
@mcspamzockt1807 9 часов назад
There's actually a Formular to calculate the kth element in the nth row when already having the last element. Then you can also use symmetry to reduce it to half.
@amythistfire5042
@amythistfire5042 4 часа назад
Plankton be stealing me formular
@technicallytechnical1
@technicallytechnical1 9 часов назад
at first i thought of using 11 squared 💀
@zanies6288
@zanies6288 10 часов назад
This can be done in O(1) as using exponents and log
@zanies6288
@zanies6288 10 часов назад
Man y'all are lucky you get asked these stupid questions in ur interviews. Here in India I have never been asked an LC ez question in an interview. Twice I've been asked LC hards in an hour long interview along with a medium question for an intern position.
@GregHogg
@GregHogg 10 часов назад
Master data structures and algorithms for FREE at AlgoMap.io :)
@ssuriset
@ssuriset 10 часов назад
Greg… you might want to correct the minheap part… minheap is actually maxheap and maxheap is minheap. I know it’s annoying but that’s just how they named it. Minheap = highest value. Maxheap = lowest value.
@opdamcha305
@opdamcha305 12 часов назад
New programmers be like if it works it works
@nithish5296
@nithish5296 12 часов назад
Why hashing dumb ass ?? Instead use XOR concept !!!!!
@thibauldnuyten2891
@thibauldnuyten2891 12 часов назад
🤦‍♂️
@DynamicalisBlue
@DynamicalisBlue 18 часов назад
What makes this dynamic programming?
@zanies6288
@zanies6288 10 часов назад
Cuz you are storing previously obtained value and using them thus minimizing redundant function calls
@DynamicalisBlue
@DynamicalisBlue 6 часов назад
@@zanies6288 didn't know that is what dynamic programming was. just sounds like programming to me.
@mohamedantar1249
@mohamedantar1249 18 часов назад
I'v watched a 20 minutes video to understand the problem, and you've explained it in 30 minutes, that's impressive
@chinmayjoshi2495
@chinmayjoshi2495 19 часов назад
5:52 he better call 'sol'
@pullurupraveen9315
@pullurupraveen9315 20 часов назад
We can take the map data structure and we can put all the letter count and we can iterate to get .
@yugjha6798
@yugjha6798 21 час назад
❤️
@SamWestonJ
@SamWestonJ 23 часа назад
I'm pretty sure this vodeo will come back to haunt you
@onebyte0
@onebyte0 23 часа назад
Take a variable a = 0. Then start traversing from last and -1 every time when you come to new index check the condition ((arr[index]-a)>=0) if true return true else false run the loop until you reach the start. If any mistake in upper code plz tell me😢
@sarthak.khanduja
@sarthak.khanduja 23 часа назад
Am I the only one who thought of Tries here?
@quesostuff1009
@quesostuff1009 День назад
Can’t you just do square root and then compare the square root value with its int casted version? I get that square rooting is quite expensive but I assume the hardware has caught up since the 90s
@jaswanthm981
@jaswanthm981 День назад
i didn't understood the question properly. someone explain
@drsmackdat
@drsmackdat День назад
Woah bicep 😊
@amumuisalivedatcom8567
@amumuisalivedatcom8567 День назад
They want you to find the 2nd higher number in the array heap, you know it's the 2nd higher because k = 2 (if k = 1 then they want the higher). To do so you arrange the array in a way you have the lowest number at the beginning and the higher at the end. Then it's simple you will compare two numbers each time and remove the lowest, when your array of numbers is only the length of k (2) then you remove the higher and return the lowest that will be the only element that's still in the array heap (so [0]) because it mean it was the second higher). Ofc you can find the same return result with one liner code BUT those will re-render the whole array until the result because they will always render the array, take the higher/lowest and kick him, then render the array again and remove again until heap lenght is reach and then give the lowest, with a heap you run through the array one single time because you do actions directly while processing (meaning you remove the higher/lowest while rending the array so the next number of the array come is treated next one come and go one until you have only the length of the array and render the lowest). That was the easy way of inderstanding it, in reality a heap is a kind of array, while processing the array heap[] (the original one) with the integers you push into your heap that's your the trash can, then you are only left with one integer in your array heap (the original one not the kind of array that a heap is) that will be the 2nd lowest because when you reach 2 integers in your array you push into the heap the higher and are left in the array heap with only the 2nd higher.. For god sake, neaming heap the heap was a headache lol In big tech you want to do the calculation fast because it will slow your server and cost you more because of electrical bills (cloud pricing), more re-render of the array = more calculs. Sorry my english is broken as my code lmao
@ninadvirkar9097
@ninadvirkar9097 День назад
We dont need to run 2 loops. Single loop would be enough with hashmap. Check if target - nums[i] exists in hashmap. If it does then you have indices at i & dict[nums[i]] else add dict[nums[i]] as i
@zetagundam20x
@zetagundam20x День назад
Messed up with #1 after solving 50 problems the optimized way 💀from here on tho, I’ll start solving the brute force way
@MohammadJNajafi
@MohammadJNajafi День назад
Basically changing recursive solution to dynamic programming solution
@coolgaming925
@coolgaming925 День назад
Python should be below f and javascript the goat
@user-uo7km6uj4x
@user-uo7km6uj4x День назад
Why you do this? What’s the point? How it helps you?