Joy of computing using python week 5 program 3| Find and Compare Kth Largest with Kth Smallest ele.

Published: 18 August 2024
on channel: VCODE LOGIC
61
0

Create a Python program that finds the
k-th largest and k-th smallest elements in a list of integers.
The program should prompt the user to input a list of integers and a value `k`.
The program should then find and print:

1 if the k-th largest and k-th smallest elements are the same and are at the middle of the sorted list.

-1 if the k-th largest and k-th smallest elements are the same but are not in the middle of the sorted list.

0 if the k-th largest and k-th smallest elements are different.

Input Format:
The first line of input consists of a space-separated list of integers.
The second line of input consists of a single integer k.

Output Format:
The output consists of a single integer 1, -1, or 0 based on the conditions specified.

Example:

Input:
3 8 7 5 9 1
2

Output:
0


Watch video Joy of computing using python week 5 program 3| Find and Compare Kth Largest with Kth Smallest ele. online without registration, duration hours minute second in high quality. This video was added by user VCODE LOGIC 18 August 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 61 once and liked it 0 people.