Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.util.stream.Collectors;
- public class SearchANumber {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- List<Integer> numList = new ArrayList<>();
- int[] inputNumbers = Arrays.stream(in.nextLine().split("\\s+"))
- .mapToInt(Integer::parseInt).toArray();
- int[] inputs = Arrays.stream(in.nextLine().split("\\s+")).mapToInt(Integer::parseInt).toArray();
- int numberElementsToTake = inputs[0];
- int numberElementsToDelete = inputs[1];
- int numberElementsToSearch = inputs[2];
- for (int i = 0; i < numberElementsToTake; i++) {
- numList.add(inputNumbers[i]);
- }
- for (int i = 0; i < numberElementsToDelete; i++) {
- if(numList.size()>0){
- numList.remove(0);
- }
- }
- if(numList.contains(numberElementsToSearch)){
- System.out.println("YES!");
- }else {
- System.out.println("NO!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement