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

 

apcsaListRemoveCloseUnder


Given an ArrayList of Integers and an int target, find the first element with the highest value lower than target. Remove that element, and return the modified ArrayList. It's possible that no elements have values less than the target, in which case no elements would be removed.


Example: suppose the ArrayList contains all the odd numbers less than 10 (e.g. 1, 3, 5, 7, 9 in order) and the target is 8, then the largest of the elements less than 8 would be 7.  The remaining elements are [1, 3, 5, 9] which is what would be returned.

apcsaListRemoveCloseUnder([3, 5, 7, 9], 8) → [3, 5, 9]
apcsaListRemoveCloseUnder([3, 5, 7, 9], 9) → [3, 5, 9]
apcsaListRemoveCloseUnder([3, 5, 7, 9], 10) → [3, 5, 7]

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

public ArrayList<Integer> apcsaListRemoveCloseUnder(ArrayList<Integer> lst, int target) { }

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

Difficulty: 220

Copyright Nick Parlante 2017 - privacy