diff --git a/GeeksforGeeks/Easy/Zeroes_to_end.java b/GeeksforGeeks/Easy/Zeroes_to_end.java new file mode 100644 index 0000000..d1ed40a --- /dev/null +++ b/GeeksforGeeks/Easy/Zeroes_to_end.java @@ -0,0 +1,14 @@ +/** +*Author: noob0412 [https://github.com/noob0412]; +*Link of the question is mentioned below +https://practice.geeksforgeeks.org/problems/move-all-zeroes-to-end-of-array0751/1# +**/ +class Solution { + void pushZerosToEnd(int[] arr, int n) { + int count = 0; + for (int i = 0; i < n; i++) + if (arr[i] != 0) + arr[count++] = arr[i]; + while (count < n) + arr[count++] = 0; + } \ No newline at end of file