FastPrepDays to Overtake Another Coder
Problems/Days to Overtake Another Coder

Days to Overtake Another Coder

JP Morgan Chase logoJP Morgan Chase● EasyINTERNFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a JP Morgan Chase online assessment, for interns or full-time. The report asks for the fewest days for one coder to strictly overtake another, from daily counts and a starting gap, or -1 if it is impossible. We chose the day-zero rule, the limits, the signature and the examples. Our version is about 95% the same as the reported task.

Coder A solves dailyA problems each day, and coder B solves dailyB each day. For this exercise, assume that at day 0 A has solved 0 problems and B has solved gap problems.

Return the smallest whole number of elapsed days after which A has solved strictly more problems than B. Being tied is not enough. Return -1 if A can never overtake B. Daily counts are constant and nonnegative.

Function

daysToOvertake(dailyA: int, dailyB: int, gap: int) → int

Examples

Example 1

dailyA = 3dailyB = 1gap = 4return = 3

After 2 days both have solved 6 problems, so the tie is insufficient. After 3 days A has 9 and B has 7.

Example 2

dailyA = 2dailyB = 2gap = 1return = -1

B starts ahead, and equal daily counts never reduce the gap.

Constraints

  • 0 <= dailyA, dailyB <= 1000000
  • 0 <= gap <= 1000000000

More JP Morgan Chase Online Assessment questions

  • Find Total CostOA · Seen Oct 2026
  • Minimum Meeting RoomsOA · Seen Oct 2026
  • Count Dropped RequestsOA · Seen Oct 2026
  • Maximize Minimum Deployment DifficultyOA · Seen Oct 2026
  • Task SchedulingOA · Seen Oct 2026
  • Substring RemovalOA · Seen Oct 2026
  • Maximum Game Board ScoreOA · Seen Sep 2026
  • Minimum Digit Changes Between String HalvesOA · Seen Sep 2026
  • Same Substring Within BudgetOA · Seen Sep 2026
  • Invert Ad Visibility BitsOA · Seen Aug 2026

Similar questions at other companies

  • Floor Square Roots for an ArrayWells Fargo · OAWells Fargo interview questions
  • Arrange CoinsAlarm.com · OA
  • Complete Rows of a Coin StaircaseExpedia · OAExpedia interview questions
  • Perfect Squares Matching a PatternNielsen · OA
  • Maximum Alloy Production Within BudgetMicrosoft · OAMicrosoft interview questions
  • Linear InterpolatorTwo Sigma · OATwo Sigma interview questions
  • Rock JumpingIMC Trading · OAIMC Trading interview questions
  • Count Lucky Numbers in a RangeTarget · OA
  • Cyber Beacon DetectionRippling · OARippling interview questions
  • Souvenir Shop PurchasesAmazon · OA

Interview reports that mention this question

  • JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)

JP Morgan Chase interview experiences

  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
  • JPMorgan Code for Good India: 10 Experiences (Part 4 of 5)
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights
Saved
class Solution {
    public int daysToOvertake(int dailyA, int dailyB, int gap) {
        // Write your code here.
    }
}
Checking account…