← Unit 4 · all exercises
Saved in this browser only

Is it in the list

Return true when the target appears anywhere in the list.

boolean has(java.util.ArrayList<Integer> list, int target)

Solution.java
Loading editor…
Results

Examples

  • Solution.has(new java.util.ArrayList<>(java.util.List.of(1, 2, 3)), 2) → true
  • Solution.has(new java.util.ArrayList<>(java.util.List.of(1, 2, 3)), 9) → false

There are also 2 hidden tests you can't see. Solve the problem, not the examples.