Leetcode 283. Move Zeroes
Vložit
- čas přidán 9. 07. 2024
- Leetcode 283. Move Zeroes
leetcode.com/problems/move-ze...
My contact details
Instagram :- / frazmohammad
Connect with me on LinkedIn :- / mohammad-f-bb4886157
Telegram Group t.me/LeadCoding
FREE INTERVIEW PREPARATION SERIES • Free Interview Prepara...
You can practice for coding interview from here
Leetcode Hard :- • Hard
Leetcode Medium :- • Medium
Leetcode Easy :- • Easy
I am Mohammad Fraz , a final year Engineer at DTU and I create content for Coding and technical interviews for FAANG. I explain the intuition to solve Data Structure and Algorithm Questions from leetcode and other platforms. I also cover interview experiences for FAANG and other tech giants. You will also find lectures on the frequently asked interview questions.
Thank you sir.
Great explanation 👌
Thankyou bhaiya for this session
i enjoing this series
how could we solve the follow-up part of this ques?
You can remove the while loop and make the nums[i] = 0 after nums[j++] = nums[i] and only when i !=j
So it'lll be like
if nums[i] != 0:
nums[j] = nums[i]
if i != j:
nums[i] = 0
j += 1
What if the elements were not sorted like 1 3 12 what if they were 0,3,1,0,12 how do we sort them after
by selection sort
Please provide a video in Hindi
class Solution {
public void moveZeroes(int[] nums) {
int a[]=new int [nums.length];
int k=0,count=0;
for(int i=0;i
else
{
nums[j]=0;
j++;
}
why this gives wrong answer
Can you send full code ?
@@mohammadfraz yes
class Solution {
public:
void moveZeroes(vector& nums) {
int n = nums.size();
int j=0;
for(int i =0;i
@@ankitkumarghosh462
Okay , take an example and try to dry run it in your code you will find the problem
@@mohammadfraz okkkkk
@@ankitkumarghosh462 did you get it?