# how to solve

• December 30th, 2013, 02:36 PM
onlydeb
how to solve
An array is initialized with n integers. Write a java program to locate all zeros in this array and shift them to the
left. The order of other numbers should not change in the array. e.g. Input: n = 10 6,10,0,89,678,8,0,64,0,3,0
Output: 0,0,0,0,610,89,678,8,64,3
• December 30th, 2013, 02:51 PM
Norm
Re: how to solve
• December 30th, 2013, 03:18 PM
andbin
Re: how to solve
Quote:

Originally Posted by onlydeb
Write a java program to locate all zeros in this array and shift them to the left.

Are you allowed to use a secondary (temporary) array? But apart this, there are several possibile solutions to this exercise, ranging from the most trivials (and not-so-smart) to others more "smart".
• December 30th, 2013, 03:34 PM
Norm
Re: how to solve
Did your instructor give any hints? Are you allowed to ask other programmer's for techniques to solve the problem? A big part of programming is finding an algorithm for solving a problem. If part of your assignment is to find a solution, then our giving you an algorithm won't be fair to other students that work it out for themselves. Writing code for a given algorithm can be half of what is required to solve a problem.