id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

konstans@stuy.edu apcs1 > moveNegatives
prev  |  next  |  chance

Given an ArrayList of Double, move all negative values to the end of the ArrayList in the same order that they originally occurred. (Do not change their relative ordering) Return the original array, not a copy. (The challenge is to do this without a 2nd array or list)


moveNegatives([]) → []
moveNegatives([-10.0, 1.0, -2.0, 3.0]) → [1.0, 3.0, -10.0, -2.0]
moveNegatives([-1.0, -2.0, -3.0, -4.0, 1.0, 2.0, 3.0]) → [1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0]

...Save, Compile, Run (ctrl-enter)

public ArrayList<Double> moveNegatives(ArrayList<Double> nums){ }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Copyright Nick Parlante 2017 - privacy