Skip to content

Instantly share code, notes, and snippets.

View mukhtiarahmed's full-sized avatar
🏠
Working from home

Mukhtiar Ahmed mukhtiarahmed

🏠
Working from home
View GitHub Profile
@mukhtiarahmed
mukhtiarahmed / AlogProblem.java
Last active September 27, 2019 09:44
Given an array numbers, write a java function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. You must do this in-place without making a copy of the array. Minimize the total number of operations. Example: Input: {0,1,0,12,11} Output: {1,12,11,0,0}
/*
Given an array numbers, write a java function to move all 0's to the end of
it while maintaining the relative order of the non-zero elements.
You must do this in-place without making a copy of the array.
Minimize the total number of operations.
Example:
Input: {0,1,0,12,11}
Output: {1,12,11,0,0}