Question: JAVA problem! Write a program that print out an array that contains exactly the same numbers as the given array, but rearranged so that every

JAVA problem! Write a program that print out an array that contains exactly the same numbers as the given array, but rearranged so that every 3 is immediately followed by a 4 and a 5. Do not move the 3's, but every other number may move. The array contains the same number of 3's, 4's and 5s, every 3 has a number after it that is not a 3 or 4, and a 3 appears in the array before any 4. (create your own input to check the result)

Sample 1

fix34({1, 3, 1, 4, 5}) {1, 3, 4, 5, 1}

Sample 2

fix34({1, 3, 1, 4, 4, 3, 1, 5, 5}) {1, 3, 4, 5, 1, 3, 4, 5, 1}

Sample 3

fix34({3, 2, 5, 2, 4}) {3, 4, 5, 2, 2}

//add more test case

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!