An Airtel Payments Bank analytics pipeline receives an unsorted array of integer transaction values. Implement a function that returns the nth largest value, counting duplicate values as separate elements.
You must avoid fully sorting the array. Use an appropriate data structure to maintain only the values needed to determine the result.
Implement nth_largest(nums, n).
nums, a non-empty list of integers, and n, a 1-indexed integer.n when nums is sorted in descending order.[7, 7, 3] is 7.def nth_largest(nums, n):