FastPrepTop Trade Events by Notional
Problems/Top Trade Events by Notional

Top Trade Events by Notional

Headlands Technologies logoHeadlands Technologies● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Headlands Technologies phone screen. The report gives events with a ticker, a price and a volume. You return the top K different tickers, ranked by the largest price times volume of any single event. The report says to cast before multiplying to avoid overflow. Here you return the original event indices. We chose a fixed tie rule, what to do with empty input or K, and the limits. Our version is about 90% the same as the reported question.

You are given three arrays of the same length, tickers, prices and volumes, that describe trade events. Event i has ticker tickers[i], price prices[i] and volume volumes[i]. Its notional is the exact product prices[i] * volumes[i].

For each different ticker, keep only its event with the largest notional. Do not add up its events. If several events of one ticker tie for the largest notional, keep the one with the smallest index.

Return the original indices of the top k kept events, from largest notional to smallest. If two tickers tie on notional, the ticker that comes first in case-sensitive ASCII order goes first. Each returned index points to one whole original event, and no ticker appears twice.

If k is larger than the number of different tickers, return every kept event in that order. If the input is empty or k == 0, return an empty array. Do not change the input arrays.

Compute and compare notionals as exact signed 64-bit integers. In C++, cast one operand to long long before multiplying. Casting an int product that has already overflowed is too late. Do not use floating-point scores.

Function

getTopTradeEventIndices(tickers: String[], prices: int[], volumes: int[], k: int) → int[]

Examples

Example 1

tickers = ["a","b","a","c","b"]prices = [10,200,100,50,10]volumes = [10,100,100,10,100]k = 2return = [1,2]

Ticker a keeps the event at 2 with notional 10000, not the sum of its events. Ticker b keeps index 1 with notional 20000, so the selected original indices are 1 and 2.

Example 2

tickers = ["b","a","a","c"]prices = [2,5,1,0]volumes = [5,2,10,999]k = 4return = [1,0,3]

Ticker a has its largest notional at both index 1 and index 2, so it keeps the earlier one, 1. Tickers a and b both have notional 10, and a comes before b in ASCII order. There are only three different tickers, so all of them are returned: a, then b, then c.

Example 3

tickers = ["x","y","x"]prices = [1000000000,999999999,1000000000]volumes = [1000000000,1000000000,999999999]k = 1return = [0]

The event at index 0 has notional 1000000000000000000, which needs an exact 64-bit product. Neither the later x event nor the y event is larger, so the answer is just this event.

Constraints

  • 0 <= tickers.length == prices.length == volumes.length <= 100000.
  • Each ticker has between 1 and 20 characters, all ASCII uppercase letters, lowercase letters or digits. Tickers are case-sensitive.
  • 0 <= prices[i], volumes[i] <= 1000000000.
  • 0 <= k <= 1000000000.
  • Every notional is at most 10^18 and fits in a signed 64-bit integer.

More Headlands Technologies Phone Screen questions

  • Integer Compression OffsetPHONE SCREEN · Seen Oct 2026
  • Market Order BookPHONE SCREEN · Seen Jun 2026
  • Gradient Descent on a Sinusoidal ObjectivePHONE SCREEN · Seen Apr 2026
  • Pearson Correlation CoefficientPHONE SCREEN · Seen Apr 2026
  • Top K Frequent ElementsPHONE SCREEN · Seen Apr 2026
  • Queue Mean from Corrective SnapshotsPHONE SCREEN · Seen Mar 2026
  • Queue Mean QueriesPHONE SCREEN · Seen Mar 2026
  • CPU Register Bitwise OperationsPHONE SCREEN · Seen Nov 2025
  • Merge K Sorted SequencesPHONE SCREEN · Seen Oct 2024
  • Fixed-Size Memory PoolPHONE SCREEN · Seen May 2024

Similar questions at other companies

  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEW
  • Worst-Performing Ads by CTR in a Campaign TreeUber · PHONE SCREEN
  • Time-Aware Search AutocompleteRoblox · PHONE SCREEN
  • Top-K Values per Key in MapReduceDatabricks · PHONE SCREEN
  • Top-K IP Addresses Across Log FilesRender · PHONE SCREEN
  • Top K Frequent Values Across Key-Partitioned ShardsJP Morgan Chase · PHONE SCREEN
  • Top-K IP Addresses from File RecordsGoogle · PHONE SCREEN · ONSITE INTERVIEW
  • Top K Frequent ElementsApple · PHONE SCREEN
  • Sort Characters by How Often They AppearAdobe · PHONE SCREEN
See Headlands Technologies hiring insights
Saved
class Solution {
    public int[] getTopTradeEventIndices(String[] tickers, int[] prices, int[] volumes, int k) {
        // write your code here
    }
}
Checking account…