2658. Count the Number of K-Big Indices

Hard
Array
Binary Search
Divide and Conquer
Binary Indexed Tree
Segment Tree
Merge Sort
Ordered Set

Description

Hints

Hint 1
The intended solution uses Fenwick Tree.
Hint 2
Let’s describe the solution for counting the number of elements smaller than nums[i] in the range [0, i - 1], and counting in the range [i + 1, nums.length - 1] can be done similarly by simply reversing the array.
Hint 3
Iterate from left to right and maintain the Fenwick Tree. Save the value of the query(nums[i]) and update nums[i] + 1 by 1.

Statistics

Acceptance
53.5%
Submissions
17,937
Accepted
9,602