FastPrepCount Routes Through a City Grid
Problems/Count Routes Through a City Grid

Count Routes Through a City Grid

IMC Trading logoIMC Trading● EasyFULLTIMENEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an IMC Trading phone screen. The goal is to count routes from one corner to the other. It is about 90% the same as the reported city-grid question. A fuller report supplies the move from the upper corner to the lower corner for a newer, shorter recollection. We chose these things: the grid is a rectangle, you only move right or down, nothing blocks the grid, there are limits, and the output is the exact count. We did not rebuild the second part of the coding exercise.

A city is represented by a rectangular grid with rows rows and columns columns. Start at the top-left cell and reach the bottom-right cell.

For this exercise, assume each step moves exactly one cell right or one cell down, every cell is open, and there is no wrapping. Count distinct step sequences that reach the destination. For this exercise, assume the grid dimensions are supplied as parameters and the result is an exact signed 64-bit count with no modulus.

A one-cell grid has one route: the empty sequence. Complete countCityGridRoutes(rows, columns).

Function

countCityGridRoutes(rows: int, columns: int) → long

Examples

Example 1

rows = 3columns = 3return = 6

Each route has two right moves and two down moves. Choosing their order gives 6 routes.

Example 2

rows = 1columns = 1return = 1

The start is already the destination, so the empty sequence is the single route.

Example 3

rows = 1columns = 5return = 1

Every step must go right, giving exactly one route.

Example 4

rows = 25columns = 40return = 156655690918541325

Choose positions of the 24 down moves among 63 steps: C(63,24)=156655690918541325. This odd integer exceeds the exact-integer range of an IEEE 754 double, so keep the count in signed 64-bit arithmetic.

Constraints

  • For this exercise, assume 1 <= rows <= 25 and 1 <= columns <= 40.
  • The largest result is 156655690918541325, which fits a signed 64-bit integer.
  • Do not use floating-point rounding to count routes.

More IMC Trading Phone Screen questions

  • Election District Budget Allocation AnalysisPHONE SCREEN · Seen Aug 2026
  • Uniform Variables: Smaller Below Larger SquaredPHONE SCREEN · Seen Mar 2026
  • Combination Sum with Unlimited ReusePHONE SCREEN · Seen Dec 2025
  • Valid Range of a Three-Outcome Probability ParameterPHONE SCREEN · Seen Dec 2025
  • Expected Fishing CatchPHONE SCREEN · Seen Dec 2025
  • Expected City Arrival and Return DaysPHONE SCREEN · Seen Nov 2024
  • Stationary City Population SharesPHONE SCREEN · Seen Nov 2024
  • Maximum Falling Path SumPHONE SCREEN · Seen Nov 2024
  • Trading Profit Percentage ChangePHONE SCREEN · Seen Feb 2024
  • Poker Suit Expected ProfitPHONE SCREEN · Seen Sep 2023

Similar questions at other companies

  • Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Heads in Fair Coin FlipsJane Street · PHONE SCREENJane Street interview questions
  • Strictly More Heads with Fewer CoinsSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Count Clean Attendance LogsRippling · PHONE SCREENRippling interview questions
  • Count Array DerangementsInMobi · PHONE SCREENInMobi interview questions
  • Count Staircases with Strictly Increasing StepseBay · ONSITE INTERVIEWeBay interview questions
  • Count Nondecreasing Digit-Sum ArraysMicrosoft · OAMicrosoft interview questions
  • Stable Workload Redistribution TreesTower Research Capital · OA
  • Count Valid A-B-C Sequences Under a Modulo-Four RuleInfosys · OAInfosys interview questions

IMC Trading interview experiences

  • IMC Trading OA: What It Tests (2026)
  • IMC Trading SWE OA and Video: 18 Experiences (Part 3 of 3)
  • IMC Trading SWE OA Questions: 22 Experiences (Part 2 of 3)
  • IMC SWE New Grad OA and Interviews: 58 Experiences (Part 1 of 3)
All IMC Trading interview questionsSee IMC Trading hiring insights
Saved
class Solution {
    public long countCityGridRoutes(int rows, int columns) {
        // Write your solution here.
    }
}
Checking account…