283. Move Zeroes | Leetcode | DSA | Java

preview_player
Показать описание
Welcome to my Daily DSA Playlist! 🎉 Here, we tackle one LeetCode problem each day, focusing on building a strong foundation in data structures and algorithms. Each video includes a deep dive into essential concepts, efficient solution strategies, and pro tips for approaching similar problems. Whether you’re gearing up for coding interviews or enhancing your problem-solving skills, this series is crafted to help you make steady progress one step at a time.

0:00 - Introduction
0:47 - Drawing Solution
4:10 - Coding The Solution

leetcode 283

Let’s master DSA together—one problem a day, every day!

#java #hashmap #CodingInterview
Рекомендации по теме
Комментарии
Автор

import java.util.*;
class Solution {
public void moveZeroes(int[] nums) {
Arrays.sort(nums);
int index = 0;
for ( int i = 0; i < nums.length; i++){
if( nums[i] == 0){
index++;
}
}
int n = 0;
int[] arr = new int [nums.length];
for ( int i = index; i < nums.length; i++){
arr[n++] = nums[i];
}

}
public static void main(String[] args){
Solution ob = new Solution();
Scanner in = new Scanner(System.in);
int size = in.nextInt();
int[] nums = new int[size];
for ( int i = 0; i < nums.length; i++){
nums[i] = in.nextInt();
}
ob.moveZeroes(nums);
in.close();
}
}



This is my code. Working in online compiler, but showing error in leetcode. Please help me to solve this

a.jeevakumar
welcome to shbcf.ru