[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jeanne Boyarsky wrote:That code doesn't compile. Take a look at where the braces are. Also, you reference a variable k that you didn't define. Did you mean j?
I will appreciate any help
fred rosenberger wrote:the problem isn't incredibly clear...are you supposed to move each integer as you find it to the front, which would reverse them, or are you supposed to find all of them, and move them en mass? in other words...if you start with this:
{ 1, 3, 3, 4, 5, 8, 0 }
when you find 4, do you move it, giving this:
{ 4, 1, 3, 3, 5, 8, 0 }
then you find 8, so you do this:
{ 8, 4 1, 3, 3, 5, 0 } and then 0, so you get this:
{ 0, 8, 4 1, 3, 3, 5 }
----OR--------
Should you find 4, 8, and 0, and move them all, giving you this:
( 4, 8, 0, 1, 3, 3, 5}
I would approach these two in different ways.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Or, if you find an odd number at the beginning, are you supposed to swap it with an odd number to its right?fred rosenberger wrote:. . . . are you supposed to move each integer as you find it . . . .