No video

LeetCode Remove Element Solution Explained - Java

  Рет қаралды 35,261

Nick White

Nick White

Күн бұрын

Пікірлер: 49
@mike19mbsc
@mike19mbsc 2 жыл бұрын
My fucking God. I was way over complicating this. I got wrapped around the axle trying to get the hint#2 method to work. The one where if you come across the target value you swap it with the end of the array. My output was all over the place. I need a moment. I want to put my head through my computer screen after seeing how simple this is. I have never wanted to quit coding as much as i do right now.
@leezhenjian7451
@leezhenjian7451 6 ай бұрын
when nick said that was the warm up it broke my heart. same as you, i implemented hint#2 successfully. But all the damned edge cases failed my code T.T
@BrendansReasons
@BrendansReasons 16 күн бұрын
I've been coding for over 10 years and I'm just starting to give leetcode a real shot. I think leetcode problems and worded terribly, and nobody knows how to explain them more like a human. Thinking of starting a channel where I work on this
@Ivan-ek6kg
@Ivan-ek6kg 4 жыл бұрын
I never comment, but you are the best! So I cant stop myself to comment you to say you are the best and most clear explanation I have ever seen.
@sheldoncooper7385
@sheldoncooper7385 3 жыл бұрын
why i can't understand 😭 I'm so bad when it's come to loop 😭
@monicawang5024
@monicawang5024 4 жыл бұрын
Perfect explanation. Thank you!
@NickWhite
@NickWhite 4 жыл бұрын
thanks for watching !
@vaibhavgaur8200
@vaibhavgaur8200 3 жыл бұрын
@@NickWhite simp :)
@alexweinberger8925
@alexweinberger8925 2 жыл бұрын
@@NickWhite hey :)
@darvyntalieh6069
@darvyntalieh6069 7 ай бұрын
It's not weird, appreciate the love man and we love you too. Hopefully, this practice is just what I need for my technical interview
@saurav0203srivastav
@saurav0203srivastav 3 жыл бұрын
Its been a month I have started my learning DSA journey and solving problems and I am still not able to think something simple like this. I was much more focused on if(nums[i] == val) which was making it more difficult and complex for me. @Nick White can you help me and tell me if i am on the right path. Id love to hear your suggestion.
@harharmahadev1038
@harharmahadev1038 3 жыл бұрын
yeah even i am stuck at that part it gives buffer overflow plus we have to build an initution of finding what shouldnt be search for the operation ....depending on the problem
@ploratran
@ploratran 2 жыл бұрын
me too. I cannot imagine this problem can be solved this easy like Nick's way.
@harnekarora5658
@harnekarora5658 Жыл бұрын
same situation , i think it's just about some practice where we can start thinking outside of the box
@thomaslao9832
@thomaslao9832 Жыл бұрын
@@ploratran it isnt solved that easily. look at his submissions.
@alieusamateh952
@alieusamateh952 8 ай бұрын
this was exactly my thinking but it didnt work
@alastairhewitt380
@alastairhewitt380 2 ай бұрын
What tripped me up in the problem description is that it doesn't say we can move the values to the back of the array, rather in the example they just leave blanks, "_". And they want us to use the in place array. Apparently in java we can't set primitive values to null, in other problem examples they set empty values to zero.... A super easy problem, but idk why they show a blank space where the val elements would go
@vishnu8643
@vishnu8643 7 ай бұрын
Oh this was very easy compared to my solution which uses two for loops one for sorting and other for counting the no of values thanks
@akware977
@akware977 2 жыл бұрын
thanks nick, for the wonderful explanation. The way you say it's easy, that confidence help to look at it without any fear. thanks for that as well.
@izhanmasoodbaba970
@izhanmasoodbaba970 Жыл бұрын
what happens to the array...when you move the non target value to the index[j]...what happens to the position where the non target element initially was ?cause we are not swapping ..right? please somebody explain
@SosetaFurioasaJr
@SosetaFurioasaJr 2 жыл бұрын
"couldn't be easier to solve" "yeah an easy problem" - meanwhile me in my second day (2 h first day) trying to wrap my brain around it... :))) thanks Nick! not helping the cause, buddy! lol
@lilyh4573
@lilyh4573 2 жыл бұрын
Lol lowkey Nick shades us every easy problem xD
@nithinss8112
@nithinss8112 4 жыл бұрын
Hey I'm new to this so how does return valid_size give a value of say [x,x] as the output?
@keshavyadav437
@keshavyadav437 4 жыл бұрын
In the problem description they've said that the length that your function returns they'll take that and return the array based on it
@cielolov2356
@cielolov2356 28 күн бұрын
Thank u so much, have a great life!!
@diproy9363
@diproy9363 Жыл бұрын
superb explanation! thanks nick.
@Makwayne
@Makwayne 3 жыл бұрын
you made it seem so easy, thank you
@mohammedghabyen721
@mohammedghabyen721 2 жыл бұрын
public class Solution { public int RemoveElement(int[] nums, int val) { int left =0; int right = nums.Length-1; while(left
@raferguo2618
@raferguo2618 4 жыл бұрын
Hope that you can put the problem number on the title for easily finding. Thanks
@cba9428
@cba9428 2 жыл бұрын
thank you so much . perfect lesson algorithms
@steve9233
@steve9233 2 жыл бұрын
This guy has some good youtube videos
@FitnessChaos
@FitnessChaos 3 жыл бұрын
Thanks for the explanation
@Rob-J-BJJ
@Rob-J-BJJ Жыл бұрын
public int removeElement(int[] nums, int val) { int N = nums.length; int L = 0, R = 1; if (N == 1) { R = 0; } while (R < N) { if (nums[L] != val) { L++; R++; } else if (nums[R] == val) { R++; } else { int temp = nums[L]; nums[L] = nums[R]; nums[R] = temp; } } return L; } Okay so i orriginally had this but was failing a couple of test cases where the array had the all the same elements, then i looked at your solution made R = 0, and got it right, im not quite sure why but im going to investigate and go thru examples.
@kunalkheeva
@kunalkheeva Жыл бұрын
Thank you!!
@edgbaston149
@edgbaston149 Жыл бұрын
Thanks 😊
@suneosama939
@suneosama939 10 ай бұрын
I love you too bro 👌🏼 thank you
@eatbreathedatascience9593
@eatbreathedatascience9593 2 жыл бұрын
How come your timing is 0 ms ?
@farhansarguroh77
@farhansarguroh77 2 жыл бұрын
aww we love you too nickk
@lilyh4573
@lilyh4573 2 жыл бұрын
LOL I can't believe he just said he loved us HOW CUTE!!!
@tomasznowak9538
@tomasznowak9538 3 жыл бұрын
Amazing!
@hellnuker753
@hellnuker753 5 ай бұрын
very good explanation, but still very confusing question hahaha
@vasanthakumarn7196
@vasanthakumarn7196 5 жыл бұрын
Hi bro. Can you give a tip for cracking product based company like Facebook? And how to start preparing problem solving from beginner to pro
@chocolateandmath497
@chocolateandmath497 4 жыл бұрын
That's a great suggestion. It would also be great if you are able to do some SQL based questions asked during interviews and maybe something in your strength area, like web development or full-stack interview prep?
@juliofils1968
@juliofils1968 3 жыл бұрын
perfect
@tarunmali6228
@tarunmali6228 2 жыл бұрын
Neat!!!!
@nileshkharatmol4916
@nileshkharatmol4916 2 жыл бұрын
Wtf I literally wasted so much time to solve this problem without using extra space I was doing shifting the numbers like that
@lilyh4573
@lilyh4573 2 жыл бұрын
This was hard for me, I did nums.remvoe(val) and then I realized that's the wrong way of doing it. UGh this was not easy for me =(
LeetCode 3Sum Solution Explained - Java
10:00
Nick White
Рет қаралды 197 М.
小丑和白天使的比试。#天使 #小丑 #超人不会飞
00:51
超人不会飞
Рет қаралды 33 МЛН
English or Spanish 🤣
00:16
GL Show
Рет қаралды 15 МЛН
Now it’s my turn ! 😂🥹 @danilisboom  #tiktok #elsarca
00:20
Elsa Arca
Рет қаралды 11 МЛН
I solved 541 Leetcode problems. But you need only 150.
7:42
Sahil & Sarra
Рет қаралды 2,3 МЛН
LeetCode Next Greater Element I Solution Explained - Java
9:51
Nick White
Рет қаралды 34 М.
LeetCode #27: Remove Element
3:21
Algo Engine
Рет қаралды 10 М.
Remove Duplicates from Sorted Array
5:41
Kevin Naughton Jr.
Рет қаралды 74 М.
Remove Element
2:19
Kevin Naughton Jr.
Рет қаралды 26 М.
LeetCode 238. Product of Array Except Self (Solution Explained)
14:49
小丑和白天使的比试。#天使 #小丑 #超人不会飞
00:51
超人不会飞
Рет қаралды 33 МЛН