020-001-008
ArrayList Search and Removal
Medium
Problem Description
ArrayList Search and Removal
In this problem, you will create a method that takes multiple strings and a search target as arguments, performs contains() search and remove() deletion on an ArrayList, and returns the results as a string.
Learning Objective: Understand search and removal operations in ArrayList
Overview
In ArrayList, you can check if an element exists with contains() and remove it with remove(). Combining these operations allows you to manage lists effectively.
Specifications
- Implement
searchAndRemove(String target, String e1, String e2, String e3, String e4, String e5)method - Add e1 through e5 to a String ArrayList
- Check if target is contained using contains()
- Remove target using remove()
- Return the search result and list after removal, separated by newline
Input/Output Example
searchAndRemove("30", "10", "20", "30", "40", "50")
→ "Contains 30: true\nAfter removal: [10, 20, 40, 50]"
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up