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.
@leezhenjian74516 ай бұрын
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
@BrendansReasons16 күн бұрын
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-ek6kg4 жыл бұрын
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.
@sheldoncooper73853 жыл бұрын
why i can't understand 😭 I'm so bad when it's come to loop 😭
@monicawang50244 жыл бұрын
Perfect explanation. Thank you!
@NickWhite4 жыл бұрын
thanks for watching !
@vaibhavgaur82003 жыл бұрын
@@NickWhite simp :)
@alexweinberger89252 жыл бұрын
@@NickWhite hey :)
@darvyntalieh60697 ай бұрын
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
@saurav0203srivastav3 жыл бұрын
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.
@harharmahadev10383 жыл бұрын
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
@ploratran2 жыл бұрын
me too. I cannot imagine this problem can be solved this easy like Nick's way.
@harnekarora5658 Жыл бұрын
same situation , i think it's just about some practice where we can start thinking outside of the box
@thomaslao9832 Жыл бұрын
@@ploratran it isnt solved that easily. look at his submissions.
@alieusamateh9528 ай бұрын
this was exactly my thinking but it didnt work
@alastairhewitt3802 ай бұрын
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
@vishnu86437 ай бұрын
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
@akware9772 жыл бұрын
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 Жыл бұрын
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
@SosetaFurioasaJr2 жыл бұрын
"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
@lilyh45732 жыл бұрын
Lol lowkey Nick shades us every easy problem xD
@nithinss81124 жыл бұрын
Hey I'm new to this so how does return valid_size give a value of say [x,x] as the output?
@keshavyadav4374 жыл бұрын
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
@cielolov235628 күн бұрын
Thank u so much, have a great life!!
@diproy9363 Жыл бұрын
superb explanation! thanks nick.
@Makwayne3 жыл бұрын
you made it seem so easy, thank you
@mohammedghabyen7212 жыл бұрын
public class Solution { public int RemoveElement(int[] nums, int val) { int left =0; int right = nums.Length-1; while(left
@raferguo26184 жыл бұрын
Hope that you can put the problem number on the title for easily finding. Thanks
@cba94282 жыл бұрын
thank you so much . perfect lesson algorithms
@steve92332 жыл бұрын
This guy has some good youtube videos
@FitnessChaos3 жыл бұрын
Thanks for the explanation
@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 Жыл бұрын
Thank you!!
@edgbaston149 Жыл бұрын
Thanks 😊
@suneosama93910 ай бұрын
I love you too bro 👌🏼 thank you
@eatbreathedatascience95932 жыл бұрын
How come your timing is 0 ms ?
@farhansarguroh772 жыл бұрын
aww we love you too nickk
@lilyh45732 жыл бұрын
LOL I can't believe he just said he loved us HOW CUTE!!!
@tomasznowak95383 жыл бұрын
Amazing!
@hellnuker7535 ай бұрын
very good explanation, but still very confusing question hahaha
@vasanthakumarn71965 жыл бұрын
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
@chocolateandmath4974 жыл бұрын
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?
@juliofils19683 жыл бұрын
perfect
@tarunmali62282 жыл бұрын
Neat!!!!
@nileshkharatmol49162 жыл бұрын
Wtf I literally wasted so much time to solve this problem without using extra space I was doing shifting the numbers like that
@lilyh45732 жыл бұрын
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 =(