Number of Ways to Reach a Position After Exactly K Steps
Updated
Problem statement
You stand at integer position startPos. Each step moves exactly one unit left or right.
Return the number of distinct step sequences that reach endPos after exactly k steps, modulo 1,000,000,007.
Function
numberOfWays(startPos: int, endPos: int, k: int) → intExamples
Example 1
startPos = 1endPos = 2k = 3return = 3Exactly two right moves and one left move are needed, which can be ordered in three ways.
Example 2
startPos = 2endPos = 5k = 10return = 0The distance and step count have different parity.
Constraints
-1000 <= startPos, endPos <= 1000.0 <= k <= 1000.
More Bloomberg LP Phone Screen questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Unique Grid PathsMorgan Stanley · PHONE SCREENMorgan Stanley interview questions
- Generate One-Two Strings with Sum NGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Median of Uniform Draws in an IntervalSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
- Winning Draws for a Mahjong HandZip · PHONE SCREENZip interview questions
- Coin Change IIApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
- Count Array DerangementsInMobi · PHONE SCREENInMobi interview questions
- Count Coin Change CombinationsDatadog · PHONE SCREENDatadog interview questions
- Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions
- Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Minimum Stores for a Shopping ListWhatNot · PHONE SCREENWhatNot interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)