Digit-Sum Sequence Join Point
Updated
Problem statement
Starting from a positive integer, build a sequence by repeatedly adding the sum of its decimal digits to the current value. For example, after 471 comes 471 + 4 + 7 + 1 = 483.
You are given the starting values s1 and s2 of two such sequences. It is guaranteed that the sequences share a value strictly below 20,000,000.
Return their first common value: the smallest integer that appears in both sequences. Each starting value is itself part of its sequence.
Function
computeJoinPoint(s1: int, s2: int) → intExamples
Example 1
s1 = 471s2 = 480return = 519The first sequence begins 471, 483, 498, 519, 534. The second begins 480, 492, 507, 519, 534. Their first common value is 519.
Example 2
s1 = 37s2 = 37return = 37Both sequences already start at the same value, so the first common value is 37.
Example 3
s1 = 91s2 = 100return = 101After 91 comes 91 + 9 + 1 = 101. After 100 comes 100 + 1 = 101. Neither starting value belongs to the other sequence before this, so the first common value is 101.
Constraints
1 <= s1, s2 < 20,000,000.- Each next value equals the current value plus the sum of its decimal digits.
- The two sequences have a common value strictly below
20,000,000.
More OpenAI Online Assessment questions
- Count Routes Through Four Shop TypesOA · Seen Oct 2026
- Network Endpoint or Cycle BoundaryOA · PHONE SCREEN · Seen Oct 2026
- Password Clues and the Next CommandOA · Seen Oct 2026
- Longest Increasing Price SubsequenceOA · Seen Oct 2026
- Macaron Order PriceOA · Seen Oct 2026
- Shortest Atom Action PathOA · Seen Oct 2026
- Simplify a Quadratic ExpressionOA · Seen Oct 2026
- Minimum-Cost Color SequenceOA · PHONE SCREEN · Seen Oct 2026
- Largest Microorganism After ConsumptionOA · Seen Oct 2026
- Invert or Blur an ImageOA · Seen Sep 2026
Similar questions at other companies
- Find Consecutive Integer SequencesIDFC Bank · OAIDFC Bank interview questions
- Fastest Average Speed over a Rolling KilometerOptiver · OAOptiver interview questions
- Paint the CeilingWeRide · OAWeRide interview questions
- Paint the CeilingRoblox · OARoblox interview questions
- Palindrome Match PercentageApple · ONSITE INTERVIEWApple interview questions
- Sparse Vector Dot Product with GPU Follow-UpNVIDIA · PHONE SCREENNVIDIA interview questions
- Order Powers of Two and ThreeAkuna Capital · PHONE SCREENAkuna Capital interview questions
- Happy NumberSnowflake · PHONE SCREENSnowflake interview questions
- Find All Pythagorean TripletsDell Technologies · PHONE SCREENDell Technologies interview questions
- Sort a Quadratic-Transformed ArrayLinkedIn · PHONE SCREENLinkedIn interview questions