FastPrepStarting Value with the Longest Collatz Chain
Problems/Starting Value with the Longest Collatz Chain

Starting Value with the Longest Collatz Chain

ZipRecruiter logoZipRecruiter● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter phone-screen report describes the Collatz steps, searching starts up to one million, and remembering the remaining chain lengths. We supplied a limit input, inclusive chain length, and a rule that the smaller value wins ties. Our version is about 91% the same as the reported question.

For a positive value n, repeatedly replace an even value by n / 2 and an odd value by 3n + 1 until reaching 1.

Among starting values from 1 through limit, return the one with the longest chain, counting both the start and 1. Break equal lengths by the smaller starting value.

Function

longestCollatzStart(limit: int) → int

Examples

Example 1

limit = 1return = 1

Only starting value one is available.

Example 2

limit = 2return = 2

Two has a longer chain than one.

Constraints

  • 1 <= limit <= 1000000
  • Intermediate values fit in signed 64-bit integers.

More ZipRecruiter Phone Screen questions

  • Neighboring Record IDsPHONE SCREEN · Seen May 2026
  • Restaurant Vote LeadersPHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2026
  • Most Frequent Word across Grouped ArraysPHONE SCREEN · Seen Sep 2024
  • Classify an Alien Dictionary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022
  • Multiset Intersection of Three ListsPHONE SCREEN · Seen Feb 2022
  • Find the Smallest Magic IndexPHONE SCREEN · Seen Dec 2021
  • Website Pair with the Most Common VisitorsPHONE SCREEN · Seen Nov 2021
  • Center-Outward Number SpiralPHONE SCREEN · Seen Jun 2021
  • Missing Ranges within Inclusive BoundsPHONE SCREEN · Seen Feb 2021
  • Fibonacci Number with Constant Extra SpacePHONE SCREEN · Seen Mar 2017

Similar questions at other companies

  • Dice-Walk Winning ProbabilityGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • 3D Grid Diagonal Walk ProbabilityApple · PHONE SCREENApple interview questions
  • Coin Game From The EndsTekion · PHONE SCREENTekion interview questions
  • Highest Die Roll WinsJane Street · PHONE SCREENJane Street interview questions
  • Median of Uniform Draws in an IntervalSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Count Array DerangementsInMobi · PHONE SCREENInMobi interview questions
  • Maximum-Product Subarray with an Empty ChoiceAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Count Staircase WaysGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • New 21 Game ProbabilityUiPath · PHONE SCREEN

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public int longestCollatzStart(int limit) {
        // Write your code here.
    }

}
Checking account…