int j = 0; for(int i = 0 ; i < nums.length ;i++){ if(nums[i]!= 0){ int temp = nums[j]; nums[j]=nums[i]; nums[i]=temp; j++; } } STEP 1: take sample variable with 0 STEP 2 : run for loop at the end STEP 3 : if arr[i] != 0 STEP 4 : then order it STEP 5 : THEN after last another elements should be zero in the array
hello akka, how many months it would take approximately for completion of this series? by the way the explanation is good , i am listening the concept daily in my bus during travel hours morning and evening and practising in home.
# code for move non zero number at the end of the array and zeroes at the starting of the array int n=arr.length; int count=n-1; for(int i=n-1;i>=0;i--){ if(arr[i]!=0){ arr[count]=arr[i]; } } for(int i=0;i
Step 1: Take a variable count to count noof zeroes step 2: Run for loop for entire array .if element is o delete zeroes and increment count for each 0 step 3:from end of array how much count is there replace with 0 s int count =0 for i in range(len(arr)): if arr[i] ==0: arr[i].pop() count ++ arr[-count:]=0
class Solution { public void moveZeroes(int[] nums) { int nonZeroIndex = -1; for (int i = 0; i < nums.length; i++) { if (nums[i] != 0) { swap(nums, ++nonZeroIndex, i); } } } private void swap(int[] nums, int i , int j) { int temp = nums[i]; nums[i] = nums[j]; nums[j] = temp; } }
class Solution { public void moveZeroes(int[] nums) { int index = nums.length-1; for(int i = nums.length-1 ; i>=0; i--){ if(nums[i]!=0){ int temp=nums[i]; nums[i]=nums[index]; nums[index]=temp; index--; }}}} this program for moveZeros to front
Hi madam Dsa poorthiga nerchukovataniki mee videos okkate saripothaya ?, leka inka emaina extra problems practice cheyyala?. Last video lo ee comment petta Konchem choosi cheppandi
Srinidhi, your face is like a beautiful mystery, each time I look at you, there's something new to discover. Your eyes are deep like an ocean, where every glance speaks a thousand emotions, reaching the soul. That smile of yours-it's simply enchanting, a charm that melts hearts in an instant. And those round spectacles? They make you look effortlessly elegant, stylish, and graceful, all at once. Your unique style and confident attitude shine through, always setting trends and winning hearts, just by being yourself.
n = len(arr)
count= 0
for i in range(n):
If arr[i] != 0:
arr[i],arr[count]= arr[count],arr[i]
count+= 1
Print(arr)
Very clear to understand😋
int j = 0;
for(int i = 0 ; i < nums.length ;i++){
if(nums[i]!= 0){
int temp = nums[j];
nums[j]=nums[i];
nums[i]=temp;
j++;
}
}
STEP 1: take sample variable with 0
STEP 2 : run for loop at the end
STEP 3 : if arr[i] != 0
STEP 4 : then order it
STEP 5 : THEN after last another elements should be zero in the array
hello akka, how many months it would take approximately for completion of this series? by the way the explanation is good , i am listening the concept daily in my bus during travel hours morning and evening and practising in home.
# code for move non zero number at the end of the array and zeroes at the starting of the array
int n=arr.length;
int count=n-1;
for(int i=n-1;i>=0;i--){
if(arr[i]!=0){
arr[count]=arr[i];
}
}
for(int i=0;i
Good video, Easy explaination.
Step 1: Take a variable count to count noof zeroes
step 2: Run for loop for entire array .if element is o delete zeroes and increment count for each 0
step 3:from end of array how much count is there replace with 0 s
int count =0
for i in range(len(arr)):
if arr[i] ==0:
arr[i].pop()
count ++
arr[-count:]=0
Thanks Srinidhi👏
Thank you for your time and knowledge sharing
nice video akka thanks for starting DSA series
for i in range(len(nums) - 1, -1, -1):
if nums[i]==0:
count+=1
nums.pop(i)
while count:
nums.append(0)
count-=1
return nums
NeetCode Sheet questions solve chesey Playlist Start cheyyandi Akka!!
Solution without Swapping (Inplace)
class Solution {
public void moveZeroes(int[] nums) {
int i=0;
for(int j=0;j
For fresher java developer ,how much DSA is required and where to start to switch to the highest package
Excellent bind blowing
Thankyou soo much ❤❤
arr = [1,2,0,5,7,0,75,79,0,45,67,3,8]
for i in range(0,len(arr)):
if arr[i] == 0:
arr.pop(i)
arr.insert(0,0)
print(arr)
We can also use swap
class Solution {
public void moveZeroes(int[] nums) {
int nonZeroIndex = -1;
for (int i = 0; i < nums.length; i++) {
if (nums[i] != 0) {
swap(nums, ++nonZeroIndex, i);
}
}
}
private void swap(int[] nums, int i , int j) {
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
Hi mam..miru chala baga cheptaru Kani naku java lo explanation kavali😢
As I said algorithm raskovadam vaste e language lo ayna code raskovachandi, btw i have discussed java solution too
Koni imp questions practice ki patu akka
class Solution {
public void moveZeroes(int[] nums) {
int index = 0;
for(int i = 0; i
class Solution {
public void moveZeroes(int[] nums) {
int index = nums.length-1;
for(int i = nums.length-1 ; i>=0; i--){
if(nums[i]!=0){
int temp=nums[i];
nums[i]=nums[index];
nums[index]=temp;
index--;
}}}} this program for moveZeros to front
class Solution {
public void moveZeroes(int[] nums) {
int j=0;
for(int i=0;i
For i in range ( len( nums)) :
If nums[i]==0 :
Count+=1
del nums[i]
For _ in range (count) :
Nums. append(0)
Return nums
My python code will it work
hlo akka dropout students ku kuda skills unte job vasthadha
Akka why don't you follow brute better optimal approaches
public class movezerostostart {
public static void main(String[] args) {
int[] arr={0,1,0,3,12,0,2,3,4,5,0,0,5};
zerostoend(arr);
for(int a:arr){
System.out.print(a+" ");
}
}
private static void zerostostart(int[] arr) {
int nonzeroindex=arr.length-1;
int zeroindex=0;
for(int i=arr.length-1;i>=0;i--){
if(arr[i]!=0){
arr[nonzeroindex]=arr[i];
nonzeroindex--;
}
}
for (int i = nonzeroindex; i >= 0; i--) {
arr[i]=0;
}
}
}
JavaScript also same scenarios?
Yes
mee LPA yentha akka?
void moveZeroes(vector& a) {
int l=0,m=0,n=a.size(),h=n-1;
while(h>=m){
if(a[m]!=0){
swap(a[l],a[m]);
l++;
}
m++;
}
}
Hi madam
Dsa poorthiga nerchukovataniki mee videos okkate saripothaya ?, leka inka emaina extra problems practice cheyyala?.
Last video lo ee comment petta Konchem choosi cheppandi
Hey entha videos chusna mi side nundi practice anedi kavali, rojuki atleast one DAA prob ayna solve cheyali
Hi akka python lo arrays levu kada
Mari Ela cheyali using list ha
Yes
@TechStoriesOfSrinidhi Thankyou akka
Meeru btech which college
IARE
Only using one loop
int j=0;
for(int i=1; i
Python
public static int[] func2(int[] arr){
int first = 0,second = 1;
for(int i=0; i < arr.length && second < arr.length;i++){
if(arr[first] == 0 && arr[second] != 0){
int temp = arr[first];
arr[first] = arr[second];
arr[second] = temp;
first++;
second++;
}else if(arr[first] == 0 && arr[second] == 0){
second++;
}
}
return arr;
}
Srinidhi, your face is like a beautiful mystery, each time I look at you, there's something new to discover. Your eyes are deep like an ocean, where every glance speaks a thousand emotions, reaching the soul. That smile of yours-it's simply enchanting, a charm that melts hearts in an instant. And those round spectacles? They make you look effortlessly elegant, stylish, and graceful, all at once. Your unique style and confident attitude shine through, always setting trends and winning hearts, just by being yourself.
Bayya ee comment edaina nibbi insta reel kinda pedithey workout avuthundi, not in tech channel like this 😂
😂😂😂😂😂@@Me-ng6ju
Bro..
1. you are totally outdated.
2. These kind of chillar efforts are useless.
3. Invest your time on something useful to you.
Wah Anna wah wah wah 😂
Hlo bro naa comment add avvatledhu
...#include
main()
{
int a[10],i,n,j=0,count=0,t;
printf("enter n: ");
scanf("%d",&n);
for(i=0;i