Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
move zeros to end of array
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class Rextester { public static void moveZeroes(int[] nums) { int pos = 0; for(int i = 0;i<nums.length;i++){ if(nums[i]!=0){ int tmp = nums[pos]; nums[pos] = nums[i]; nums[i] = tmp; pos++; } } for(int i:nums) System.out.print(i+","); } public static void main(String args[]) { System.out.println("Hello, World!"); moveZeroes(new int[]{1,0,2,3,0,4}); } }
run
|
edit
|
history
|
help
0
currency.java
add
Display Page (Pagination)
How many Squares in Rectangle
1.5
Leetcode 937. Reorder Log Files๐ฎ๐ณ๐ฎ๐ณ๐ฎ๐ณ
2(B)
Java recursive test
Leetcode 17. Letter Combinations of a Phone Number
MP8 game