Remove the First Match Using Two Helpers
easyQuestion 558A class that already has good helpers should use them. indexOf finds where a value sits and removeAt closes the gap at a position, so removing by value is those two calls joined by one check. size is the number of slots in use (the array data may be longer), and both helpers already respect it.
Requirements:
1. removeValue(int value) removes the first slot in use that holds value and returns true.
2. It returns false and changes nothing when the value is not in the list.
3. Call indexOf and removeAt. Do not write a new loop.
Do NOT write a main method.
Expected output
true [9, 4, 6] true [9, 4] false [9, 4] 2
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Data Structures & AlgorithmsDynamic Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.