Question
Let the user input a sequence of positive integers by Scanner, and this number sequence shall be stored in an array. The length of this
Let the user input a sequence of positive integers by Scanner, and this number sequence shall be stored in an array. The length of this array is set to be less than 1,000,000. The value of every number in this array is greater than 0 and less than or equal to 231-1. The number sequence shall end with -1. After the number -1, a number k will also be given by the user. Your job is to find the next number in the array after k. Please print your result to the console.
If the length of this array is 0, please print DNE.
If k does not exist in this array, please print DNE.
If k is located at the end of this array, please print DNE.
If the array contains duplicating ks, please find the next number after the first k.
Sample input/output:
Input
20 32 6 54 12 20 -1 6
Output
54
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started