Algorithm · Microsoft · Medium
You are given an integer array nums and an array of indices called query. For each index i in query, look at the suffix of nums that begins at position i and runs to the end of the array. Count how many times the maximum value inside that suffix appears. Return an array containing these counts, preserving the order of the queries. Constraints: 1 ≤ nums.length, query.length ≤ 10⁵ 0 ≤ query[i] ≤ nums.length - 1 -10⁹ ≤ nums[i] ≤ 10⁹ Example 1: Input: nums = [7, 5, 7, 2, 7],…
Checking your access…