Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

=+ f. instituting laws against driving while intoxicated

Answered: 1 week ago