TECHNO-TUNING
C,C++,Linux,Android, Imaging, Codecs, System software understanding
Sunday, November 12, 2017
Movnig the zeores in the given array towards the end without changing non zero number orders in the array
void moveZeroes(int* nums, int numsSize) {
int i;
int j = 0;
if (!nums || numsSize < 2)
return;
for(i=0; i<numsSize; i++) {
if (nums[i]!=0) {
nums[j] = nums[i];
j++;
}
}
for(;j< numsSize; j++) {
nums[j] = 0;
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment