FastPrepTop K Trades
Problems/Top K Trades

Top K Trades

Jane Street logoJane Street● EasyINTERNFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in eleven Jane Street interview reports from 2022 to 2026, for trading desk operations roles, in the coding interview. Most candidates were asked for the three biggest trades in a list, often in one pass and without library helpers or a full sort. Several were then asked to handle any k, to make it faster, or to think about short sells with negative sizes. One report asks for the top k prices directly.

We use the top k version and return the sizes from largest to smallest. The limits, the positive sizes and all examples are our own; the short-sell follow-up is covered in the editorial.

Our version is about 90% the same as the reported question.

A trader gives you today's trades as an array trades, where trades[i] is the size of trade i. The trader wants to see the biggest ones.

Return the k largest sizes, from largest to smallest. Trades with the same size are counted separately, so a size can appear more than once in the answer.

Try to do better than sorting the whole array.

Function

topKTrades(trades: int[], k: int) → int[]

Examples

Example 1

trades = [5,1,9,3,7,9]k = 3return = [9,9,7]

Sorted from largest to smallest the sizes are 9, 9, 7, 5, 3, 1. The first three are 9, 9 and 7. Both trades of size 9 count.

Example 2

trades = [40,10,30,20]k = 2return = [40,30]

The two largest sizes are 40 and 30.

Example 3

trades = [8]k = 1return = [8]

There is only one trade, so it is the answer.

Example 4

trades = [6,6,6,6]k = 4return = [6,6,6,6]

All four trades have size 6, and k = 4 asks for all of them.

Constraints

  • 1 <= trades.length <= 105
  • 1 <= trades[i] <= 109
  • 1 <= k <= trades.length

More Jane Street Phone Screen questions

  • Maximum-Scoring Consecutive Tree LevelsPHONE SCREEN · Seen Nov 2026
  • Tree Selection and VisibilityPHONE SCREEN · Seen Nov 2026
  • Load/Store Arithmetic InterpreterPHONE SCREEN · Seen Oct 2026
  • Instrument Stack Language JumpsPHONE SCREEN · Seen Oct 2026
  • Run a Stack Language InterpreterPHONE SCREEN · Seen Oct 2026
  • Positive-Integer Expression EvaluationPHONE SCREEN · Seen Oct 2026
  • Add Two Integers Given as StringsPHONE SCREEN · Seen Sep 2026
  • Angle Between Clock HandsPHONE SCREEN · Seen Jul 2026
  • Route Length From Two CyclistsPHONE SCREEN · Seen Jul 2026
  • Sort TradesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • Merge Three Sorted ArraysMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Merge Three Sorted ArraysSambaNova Systems · PHONE SCREENSambaNova Systems interview questions
  • Top K Largest Values with Constant Auxiliary SpaceBAMTECH Media · PHONE SCREEN
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN
  • Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
  • Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
  • Median Across Sorted ArraysGoogle · PHONE SCREENGoogle interview questions
  • Select the Top User MatchesDuolingo · PHONE SCREENDuolingo interview questions
  • Meeting Rooms IIQuince · PHONE SCREENQuince interview questions

Interview reports that mention this question

  • Jane Street TDO UK and Hong Kong: 22 Experiences (Part 10 of 10)
  • Jane Street TDOE US Final Round: 11 Experiences (Part 5 of 10)
  • Jane Street TDOE UK Coding Round: 15 Experiences (Part 3 of 10)
  • Jane Street TDOE UK Final Round: 14 Experiences (Part 2 of 10)
  • Jane Street TDOE Interviews: 165 Experiences (Part 1 of 10)
  • Jane Street TDOE Intern Interview Questions: 8 Experiences
All Jane Street interview questionsSee Jane Street hiring insights
Saved
class Solution {
    public int[] topKTrades(int[] trades, int k) {
      // Write your code here.
    }
}
Checking account…