Question: Find kth Largest Element in a Stream Description Given an infinite stream of integers, find the kth largest element at any point in time. Input

Find kth Largest Element in a Stream

Description

Given an infinite stream of integers, find the kth largest element at any point in time.

Input Format:

The first line contains an integer N as the size of the stream.

The second line contains an integer K representing the position of the largest number.

The third line contains elements of the stream of size N.

Output Format:

The output contains the kth largest number at any point in time. If the kth largest number does not exist, then print None (without quotes and with capital letter N).

Sample Test Cases:

Input:

8

3

20 30 21 80 60 50 110 15

Output:

None

None

3 largest number is 20

3 largest number is 21

3 largest number is 30

3 largest number is 50

3 largest number is 60

3 largest number is 15

Input:

5

2

10 40 11 20 60

Output:

None

2 largest number is 10

2 largest number is 11

2 largest number is 20

2 largest number is 40

 Find kth Largest Element in a Stream Description Given an infinite
please use with JAVA programming language

10:31 AM Tue Jan 26 98% Find kth Largest Element in a Stream Description Given an infinite stream of integers, find the kth largest element at any point in time. Input Format: The first line contains an integer 'N' as the size of the stream The second line contains an integer 'K' representing the position of the largest number. The third line contains elements of the stream of size 'N Output Format: The output contains the kth largest number at any point in time. If the kth largest number does not exist, then print 'None' (without quotes and with capital letter "N"). Sample Test Cases: Input: 8 3 20 30218060 50 110 15 Output: None None 3 largest number is 20 3 largest number is 21 3 largest number is 30 3 largest number is 50 3 largest number is 60 3 largest number is 15

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!