LeetCode Challenge Day 4 - First Good Problem?

  Рет қаралды 43,879

Errichto Algorithms

Errichto Algorithms

Күн бұрын

Пікірлер: 160
@AshishKumar-jj7yw
@AshishKumar-jj7yw 4 жыл бұрын
One suggestion Kamil. As these problems seem incredibly standard as far as coding interviews are concerned, maybe after solving the problem, you can challenge us with some variant that you can construct.
@jameshello38
@jameshello38 4 жыл бұрын
Yeah that would be awesome.
@djBC10000
@djBC10000 4 жыл бұрын
just go practice leetcode lol, you MIGHT think that you solved his variant, but no one will be able to provide enough test cases. so just go practice leetcode, that will give you a run for your money.
@navneethingankar6486
@navneethingankar6486 4 жыл бұрын
one variant is given the same question you have a given additional integer x, you have to move all less than equal to x to end preserving the original order. and all remaining to front.
@Errichto
@Errichto 4 жыл бұрын
I started doing it, thanks for a suggestion ;)
@Philgob
@Philgob 2 жыл бұрын
this guy’s code is clean asf and his explanation are the best i’ve seen for these
@ronaldabellano5643
@ronaldabellano5643 4 жыл бұрын
You’re really good at explaining better than AlgoExpert
@clem
@clem 4 жыл бұрын
I mean...Errichto _is_ an AlgoGod after all.
@mugi1726
@mugi1726 4 жыл бұрын
@@clem AHAHAHAHHAHA
@manowabdiaziz
@manowabdiaziz 4 жыл бұрын
@@clem and boom clement is there 😂😂 . Take ericho to the company
@vishalparmar1999
@vishalparmar1999 4 жыл бұрын
@@clem Haha, Simplicity level : INT_MAX
@occo5877
@occo5877 4 жыл бұрын
Clément Mihailescu you should really consider having him explaining the solutions. The idea of short video explanations and code walkthrough is great but what algoexpert is missing is an expert like errichto :) he will change your platform otherwise I can find hundreds of mediocre dudes on KZbin explaining algorithms :)
@Kumarsivam003
@Kumarsivam003 4 жыл бұрын
Your explanation is by far the most suitable explanation, not only in this video but every video you have ever uploaded. Also, I am no expert in coding but this algoexpert advertisement is creeping in every coding youtube channel I search nowadays.
@dragonore2009
@dragonore2009 3 жыл бұрын
I'm terrible at algorithms, I'm glad the company I work for didn't ask tough questions and I"m still employed with them, doing great things.
@KrishNa-hm8mk
@KrishNa-hm8mk 4 жыл бұрын
8:26. Totally what I needed to hear. I was feeling low for not able to think of a solution for Max subarray. Never knew Kadane's algorithm existed. But since you said this I feel that I need to discover more topics and learn as and when a new topic arises. Cheers 🙌
@pratiyushprakash6509
@pratiyushprakash6509 4 жыл бұрын
I started Leetcode for fun because of lock-down. And now I am enjoying it. Thanks bro :) Subscribed.
@AlokKumar-jh8wp
@AlokKumar-jh8wp 4 жыл бұрын
Thankyou Errichto. The way you explain is incredible. You should launch your own course on data structures and algorithms. I remember the most valuable statement which was told in previous videos: - “Thinking is more important in programming”. These are golden lines
@Francisco-zi2qg
@Francisco-zi2qg 4 жыл бұрын
I couldn't agreed more on your final thought, that's why so many people gets frustrated when starting competitive programming. If myself of fifteen years ago have seen this video it would had been much easier, well by that time there weren't KZbinrs. Excellent work and thanks.
@_GabrielNexT
@_GabrielNexT 4 жыл бұрын
The quality gets better with each video. Congratulations bro!
@arthurg5966
@arthurg5966 4 жыл бұрын
Please make Code Jam 2020 solutions video especially the 3rd, 4th and 5th question. Also your explanation is really awesome. Not too difficult to understand nor fells like too much spoon feeding just perfect. This channel feels like my 1 stop to all my competitive programming needs.
@TOpCoder100
@TOpCoder100 4 жыл бұрын
Would be extremely helpful!
@jimwoodward7293
@jimwoodward7293 4 жыл бұрын
These videos are great -- your explanations are so straight forward and logical.
@vijay6877
@vijay6877 4 жыл бұрын
The category of this video is Education. Now legend is not playing sports but become the coach. btw love your videos.
@chai1817
@chai1817 4 жыл бұрын
Loving this series! Will we see a Code jam Quals video soon? Would love to hear your explanation of those last two problems! Keep up the great work!
@dantran6192
@dantran6192 4 жыл бұрын
I also looking forwards to the Google Code Jam Qualification video explanation. The last problem has so many maths theorems.
@stonecoldcold2941
@stonecoldcold2941 4 жыл бұрын
Love this serie bro! I want to see you uploading for all 30 daus
@siddharthpanigrahi3855
@siddharthpanigrahi3855 4 жыл бұрын
if you use index , then you can swap nums[next] and nums[i]. you wont have to put zeros in end.
@cactusbee8474
@cactusbee8474 4 жыл бұрын
Great! You have amazing talent to explain solution. Not everyone has that talent. Good luck!
@abdelrahmanadel8998
@abdelrahmanadel8998 4 жыл бұрын
Your explanation is fantastic plz do playlist for algorithms
@mohammedshoaib1635
@mohammedshoaib1635 4 жыл бұрын
I like Errichto’s video, then I watch it because I know it’s going to be good.
@user-dj9ul7vq5q
@user-dj9ul7vq5q 2 жыл бұрын
Sigma Rule: Submit the solution, without testing... 😂 Errichto is on the God Level
@houssem8597
@houssem8597 4 жыл бұрын
Love the daily uploads great content
@stefanogagliardi4665
@stefanogagliardi4665 4 жыл бұрын
Very good from Italy. Last for cycle to get difference of size (so add n 0 to the end) is very ingenious. Best regards!
@saikiranangalakudhiti5677
@saikiranangalakudhiti5677 4 жыл бұрын
Awsm idea..! After i seeing this question i did using the swap operation it made to complete in 3 lines and 30sec.. but thinking like you practically is my aim.. thnx for the new thought
@mayukhchanda5805
@mayukhchanda5805 4 жыл бұрын
Thank you for making these videos. I am taking this challenge and so far your videos have helped me a lot to understand and learn better ways to solve problems. Please keep up this series.🙏🙏 Really appreciate the videos
@jay-rathod-01
@jay-rathod-01 4 жыл бұрын
Well I felt todays problem was easier than the previous one's.
@jonmichalak7346
@jonmichalak7346 4 жыл бұрын
keep it up man, you're a beast. i learn a lot from your solutions
@PoorSkill
@PoorSkill 4 жыл бұрын
your explanations are so good
@secretmystery8305
@secretmystery8305 4 жыл бұрын
Hey you are a great man. Your a knowledge powerful man on computer programming.
@learnstochastic
@learnstochastic 4 жыл бұрын
Errichto's sense of humour.❤️
@occo5877
@occo5877 4 жыл бұрын
I would buy algoexpert only if you were presenting in the videos :) Since you are an indeed an expert, you bring a totally different view to the problem when you are explaining it. You have the experience to give the big picture that algoexpert doesn’t. At least from the one free video I tried to watch. Please make more series like this. I would gladly pay you :)
@solvingcodingchallenges1913
@solvingcodingchallenges1913 4 жыл бұрын
Wow. Your skills are impressive.
@w47-p1e
@w47-p1e 4 жыл бұрын
sorting the vector with comparator (x!=0 && y == 0) would solve it in one line. :)
@asdfg6528
@asdfg6528 4 жыл бұрын
thanks for explaining line by line
@shahirabdullah5438
@shahirabdullah5438 4 жыл бұрын
Thank you so much for making such kind of videos.
@elandor3084
@elandor3084 4 жыл бұрын
ty Errichto
@jeffkirchoff14
@jeffkirchoff14 4 жыл бұрын
def move_zero(list): empty=[] for i in list: if i !=0: empty.append(i) count=list.count(0) for s in range(count): empty.append(0) print(empty) move_zero([1,4,0,2,0,6,8,0,1,5])
@seanpe6480
@seanpe6480 4 жыл бұрын
This works but is not an in place algorithm. You're creating a duplicate array, which creates a space complexity of O(n). It works though!
@MetalNeo91
@MetalNeo91 4 жыл бұрын
here is my solution : def order(L): a = [] b = [] for i in range(len(L)): if L[i] == 0: a.append(L[i]) else : b.append(L[i]) return b+a print(order([1,0,0,1,1])) print(order([0,1,0,3,12]))
@shahanahmed952
@shahanahmed952 4 жыл бұрын
Great Video Erricto! The explanation was done marvelously keep doing it like this! Also I'll be sure to checkout Algoexpert like you said for support. Cheers!
@anjanas_life
@anjanas_life 4 жыл бұрын
Congrats on your first youtube ad/promo
@maikopskoy
@maikopskoy 4 жыл бұрын
Damn this was well explained. I already feel a bit better
@НикитаШуляк-б6в
@НикитаШуляк-б6в 4 жыл бұрын
The eazsiest solution for this problem is to use a method like in bubble sort :) When you come up agains with 0, move them till the end while swapping him with other elements. It would take quadratic TC but constant space, which reqired.
@Britas1030
@Britas1030 4 жыл бұрын
I haven't watched the video. Yet I see the timer and knowing that it is a good problem.
@ialpha6431
@ialpha6431 4 жыл бұрын
We can also swap `nxt` with `i` in the first for loop and be done with it right there.
@atharvjain5424
@atharvjain5424 4 жыл бұрын
have you ever tried doing usaco solution guides? that would be really helpful... keep up the good content!
@reformed_attempt_1
@reformed_attempt_1 4 жыл бұрын
It's definitely possible to come up with solution for max subarray sum and xor. Takes about 2 hours, but possible
@raulpodar5994
@raulpodar5994 4 жыл бұрын
Hi @Errichto, I really like this series. What do you use for drawing ? Is it a drawing tablet ?
@vineetkothari398
@vineetkothari398 4 жыл бұрын
A video on Google Code Jam qualifiers,especially the last 2 questions,would be very helpful!
@imdeadshot3632
@imdeadshot3632 4 жыл бұрын
please upload codejam 2020 qualification round discussion video! thanks in advance!
@adilkhatri7475
@adilkhatri7475 4 жыл бұрын
Excellent!!!!!
@ItumelengS
@ItumelengS 4 жыл бұрын
Thank you.
@sufyan2317
@sufyan2317 4 жыл бұрын
👌👌👌👌👌👌
@Aditya-us5gj
@Aditya-us5gj 4 жыл бұрын
Errichto, can you please tell the runtime and memory consumption of your solution ?
@ezdp
@ezdp 4 жыл бұрын
will you upload a screencast/explanation of Google Codejam Qualification Round?
@CarrotCakeMake
@CarrotCakeMake 4 жыл бұрын
Loved it great video.
@dscmtr686
@dscmtr686 4 жыл бұрын
For me this problem is similar to removing duplicates from sorted array in O(n).
@anandkanade9500
@anandkanade9500 4 жыл бұрын
You can use partition in C++ stl
@SamDaBest
@SamDaBest 4 жыл бұрын
I think changing nums[nxt]=x to swap this two numbers will be faster You will only need one for loop
@prakash_77
@prakash_77 4 жыл бұрын
Did you see it in the solution? Where it discussed the sub-optimal vs optimal approach?
@SamDaBest
@SamDaBest 4 жыл бұрын
Prakash Arora I actually solve with this way
@prakash_77
@prakash_77 4 жыл бұрын
@@Catalyz7 It is same complexity wise but we don't have to iterate through the loop twice. In worst case, all zeroes result in traversing whole array twice. Therefore, swapping solution is optimal. Comparing swap operation to assignment operator is immaterial. Doesn't make much difference. Assignment is either way a fast operation. Swapping is just two assignments.
@jameshello38
@jameshello38 4 жыл бұрын
1:03 was that real or just some sound effect?
@djBC10000
@djBC10000 4 жыл бұрын
brah it is real lol
@miguelperezpal
@miguelperezpal 4 жыл бұрын
Great content!
@divineforever8691
@divineforever8691 4 жыл бұрын
can u make a video on problems on this codejam.
@luisresendiz3221
@luisresendiz3221 4 жыл бұрын
The same solution, perfect
@TheAceInfinity
@TheAceInfinity 4 жыл бұрын
Very nice videos :)
@xNiickT
@xNiickT 4 жыл бұрын
Nice video thank you. Is the time complexity O(n logn) ?
@prakash_77
@prakash_77 4 жыл бұрын
O(n) because we are just traversing the array. And there are n elements in the array. Worst case will be O(n+n) ~ O(n) (when all elements are zeroes).
@xNiickT
@xNiickT 4 жыл бұрын
@@prakash_77 Okay, thanks mate
@cobrandrewg9995
@cobrandrewg9995 4 жыл бұрын
Code jam qualifiers tutorial please!!!
@baburayhanshaik5121
@baburayhanshaik5121 4 жыл бұрын
you are my dhronacharya
@suhendar977
@suhendar977 4 жыл бұрын
youre so amazing ! please make an apps that have a case and you tell us how to solve it. gonna be amazing series thank you !
@andrewlei2980
@andrewlei2980 4 жыл бұрын
Can you also do: count how many zeros, delete all zeros in the array, append an array of zeroes to the start of the array.
@UNDAGROUNDCREEP
@UNDAGROUNDCREEP 4 жыл бұрын
Can I get the advice from any of you, guys. Should I learn C# - > JS/C++ or JS - > C# - > C++? Is it better to start from simpler languages to eventually stick to C++? Share own experience, thanks in advance
@luisoncpp
@luisoncpp 4 жыл бұрын
My experience: First I tried to learn C and I failed, then I learned PHP and I started to feel more familiarized with many elements of the C syntax, then I started to learn C++ and it was much easier than when I tried C first. The C++ syntax even seemed simpler than the syntax of C, and even simpler than those java codes that I had seen at that time and seemed pretty intimidating. Through the years I learned about a bunch of things that I missed on my first try on C++ and why it's considered to be more complicated than Java. If you are only programming out of curiosity, as a hobby, I think you would have a better time learning C++ than learning Java. You can playing with few elements of C++ pretty quickly but Java seems more convoluted at the beginning. This is because C++ let you start using it as a structured programming language and leave the objects for later, but in Java you need to start with object oriented programming right from the start.
@pushpam_kumar_
@pushpam_kumar_ 4 жыл бұрын
Make video on Google Code Jam Qualification Round Solutions.
@II_xD_II
@II_xD_II 4 жыл бұрын
I got an approach scan number of zeros in an array then count them add equal number of zeros at the end.
@isytadrug7085
@isytadrug7085 4 жыл бұрын
you forgot to delete the zeros before re-adding them at the end
@II_xD_II
@II_xD_II 4 жыл бұрын
@@isytadrug7085 i think thats what you did to me :)
@TarequeMdKhan
@TarequeMdKhan 4 жыл бұрын
I was finding difficult to understand your voice earlier. I'm able grasp your English now.. it's quite different than your first video. :)
@booklal
@booklal 4 жыл бұрын
Plz make video of solution of last problem of code jam qualification round
@djBC10000
@djBC10000 4 жыл бұрын
here is how i solved it: void moveZeroes(vector& nums) { int j = 0; for(int i = 0; i < nums.size(); i++) if(nums[i] != 0) swap(nums[i], nums[j++]); }
@silverzero9524
@silverzero9524 4 жыл бұрын
same but in python
@navneethingankar6486
@navneethingankar6486 4 жыл бұрын
try the variant i provided with the same approach of yours. (you have a given additional integer x, you have to move all less than equal to x to end preserving the original order. and all remaining to front.)
@djBC10000
@djBC10000 4 жыл бұрын
@@navneethingankar6486 Okay thanks for the question. for your variant, i would use my function above and check for all of the elements that are
@navneethingankar6486
@navneethingankar6486 4 жыл бұрын
@@djBC10000 but you have changed the order of elements
@djBC10000
@djBC10000 4 жыл бұрын
@@navneethingankar6486 only the order of the elements that are bigger than x, the order of the elements that are smaller than x is preserved and those elements will be at the end of the array. Do you also want the order of the elements that are bigger than x to be preserved?
@jassimmohammed5643
@jassimmohammed5643 4 жыл бұрын
I think swapping is a bit faster since it will traverse the sequence only once
@danishirfan9317
@danishirfan9317 4 жыл бұрын
Please make video on codejam 2020 qualification round
@karansagar7870
@karansagar7870 4 жыл бұрын
I saw u at number 2 code jam
@malkeetsapien4852
@malkeetsapien4852 2 жыл бұрын
Litt video 🔥
@fiziblank2609
@fiziblank2609 4 жыл бұрын
will you update video of code jam?
@nawnaw2315
@nawnaw2315 4 жыл бұрын
3:14am here and still watching
@djkassir2008
@djkassir2008 4 жыл бұрын
But using some stl features, we can solve this problem just in one line: fill(remove_if(nums.begin(), nums.end(), [](int x) { return x == 0; }), nums.end(), 0);
@viktorpenelski3265
@viktorpenelski3265 4 жыл бұрын
@Errichto What software/input device are you using for the drawing-on-screen part?
@Coder_DhruvArora
@Coder_DhruvArora 3 жыл бұрын
A pentab maybe
@ascyrax8507
@ascyrax8507 4 жыл бұрын
kamil..u the best
@cocoarecords
@cocoarecords 4 жыл бұрын
what does the question mark inside an index do? eg: [?] i googles found nothing
@MetalNeo91
@MetalNeo91 4 жыл бұрын
def order(L): a = [] b = [] for i in range(len(L)): if L[i] == 0: a.append(L[i]) else : b.append(L[i]) return b+a print(order([1,0,0,1,1])) print(order([0,1,0,3,12])) took me 30s, just create two empty list, in one u put all 0's everyone else in the other list.
@rajdave9862
@rajdave9862 4 жыл бұрын
From where Did you learned c++? How can I learn c++ as like you know?
@lvanishkoul1667
@lvanishkoul1667 4 жыл бұрын
Make a video on code jam qualification round
@mursalinahmed3463
@mursalinahmed3463 4 жыл бұрын
Can you say what vector syntax do?
@peepforlearning6058
@peepforlearning6058 4 жыл бұрын
what pen and software pad u are using to write on screen.....
@abdullahalattar5642
@abdullahalattar5642 4 жыл бұрын
well it could solved with a single line, std::stable_partition(nums.begin(), nums.end(), [](int n){return n!=0;});
@AshishKumar-hh9dw
@AshishKumar-hh9dw 2 жыл бұрын
Hey man, can you tell me the name of that online blackboard that you using?
@user-ji7mq7sn6w
@user-ji7mq7sn6w 4 жыл бұрын
Best
@jeremydurand8656
@jeremydurand8656 4 жыл бұрын
Is it bad to remove and append elements in the array?
@aanchalsharma5264
@aanchalsharma5264 4 жыл бұрын
I have a doubt function movezeroes's return type is void Then how we can return nums ?🤔 I am confused Please help
@uniqjohni1976
@uniqjohni1976 4 жыл бұрын
He commented it out later in the video. :)
@aanchalsharma5264
@aanchalsharma5264 4 жыл бұрын
@@uniqjohni1976 oh yes
@sharudesu
@sharudesu 4 жыл бұрын
i was able to solve the first 3 problems in google code jam (because they are easy) but got no idea how to solve the other 2 :(
@NotFound-hy7qb
@NotFound-hy7qb 4 жыл бұрын
Where is codejam video?
@soepet
@soepet 4 жыл бұрын
Couldn't you just go through the array, remove all 0 and later add currentLengthOfArray - startingLengthOfArray 0 at the end? That wouldn't need nxt and so on
@prakash_77
@prakash_77 4 жыл бұрын
But that would be O(n square) solution. Erase function in vector is O(N+M) where N is no. of elements erased and M is no. of elements moved. Here although N is 1 but still it's a O(n) approach. When inside the loop, in worst case when all elements are zeroes, complexity will be O(n square) because we will call it for every element.
@prakash_77
@prakash_77 4 жыл бұрын
@@jalsol But when you remove the 0, all elements after it are moved to a lesser index (vector is just a dynamic array), in worst case all n elements. That's why it's an O(n) operation.
@YoannBuzenet
@YoannBuzenet 4 жыл бұрын
I dont know c++ could you do it in python?
@rajdave9862
@rajdave9862 4 жыл бұрын
How are you able to think too much fast?
@TwoTeaTee
@TwoTeaTee 4 жыл бұрын
Your leetcode profile picture is rotated. ‼️
@abhinavgupta5893
@abhinavgupta5893 4 жыл бұрын
I wasted too much time not understanding array out of bounds error while coding in cpp
@Paradise-kv7fn
@Paradise-kv7fn 4 жыл бұрын
i solved it recurision + memo in around 20 lines...didn't even realize that it can be solved in 3 lines...*sigh* :/
LeetCode Challenge Day 5 - Buy and Sell Stock II
6:08
Errichto Algorithms
Рет қаралды 47 М.
HARD Constructive Problem E | Google Code Jam 2020 Qual Round
21:41
Errichto Algorithms
Рет қаралды 24 М.
Lazy days…
00:24
Anwar Jibawi
Рет қаралды 8 МЛН
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 8 МЛН
Мама у нас строгая
00:20
VAVAN
Рет қаралды 12 МЛН
LeetCode Challenge Day 7 - Too Easy? Harder Version!
12:44
Errichto Algorithms
Рет қаралды 26 М.
(HARD?) LeetCode Day 9 - Backpace String Compare in O(1) Space
13:35
Errichto Algorithms
Рет қаралды 28 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 705 М.
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 161 М.
The KEY To Thinking Like a Programmer (Fix This Or Keep Struggling)
10:39
Facebook Hacker Cup 2020 Finals
12:23
Errichto Algorithms
Рет қаралды 88 М.
Best time to buy and sell stock with cooldown | Leetcode #309
34:31
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 308 М.
Hardest Advent of Code 2020 Problem (day 20 Jigsaw, backtracking)
11:06
Errichto Algorithms
Рет қаралды 39 М.