Math, asked by yashrrtttt8216, 1 year ago

Given an integer array, find if an integer p exists in the array such that the number of integers greater than p in the array equals to p

Answers

Answered by Anonymous
28

 \large\boxed{\underline{\mathcal{\red{A}\green{n}\pink{s}\orange{w}\blue{e}\red{r:}}}}

Noble integers in an array (count of greater elements is equal to value)

Given an array arr[ ], find a Noble integer in it. An integer x is said to be Noble in arr[ ] if the number of integers greater than x are equal to x. If there are many Noble integers, return any of them. If there is no, then return -1.

Examples :

Input : [7, 3, 16, 10]

Output : 3

Number of integers greater than 3 is three.

Input : [-1, -9, -2, -78, 0]

Output : 0

Number of integers greater than 0 is zero.

Answered by Anonymous
0

Answer:

Simplify InputThis problem is not very difficult but to solve it we have to apply a well known technique to simplify the given inputs.Let’s take a small example:2, 6, 1, 3This input should return 1 as 2 is a noble integer. We know that by counting the number of integers greater than 2 (3 and 4).

Similar questions