← Upstart Interview Insights

Upstart·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Interviewed for a software engineering role at Upstart and got a math-meets-indexing problem that looked straightforward but had a few edge cases I didn't think through fast enough.

Questions Asked (1)

Q1

Given three integers num1, num2, and sum, find the first digit index (starting from index 0 at the ones place) where the provided sum differs from the actual result of num1 + num2.

Algorithms & Data Structures
Author's notes

Took me a second to realize the tricky part isn't the arithmetic, it's the digit extraction and handling the case where the two numbers have different lengths.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Iterate through each digit position from the ones place upward, comparing the digit of the given sum with the corresponding digit of the actual sum (num1 + num2). At each step, extract the digit using modulo 10 and integer division by 10, and return the index where they first differ. If all digits match up to the maximum length, return -1 to indicate no difference.

Pro tip: Clarify edge cases upfront, such as when the given sum matches the actual sum entirely or when one number has more digits than the other. Also, mention that you can avoid computing the full sum by using digit-wise addition with carry, which is more memory-efficient for very large numbers.

1. Understand the problem and edge cases

Restate the problem to ensure clarity: find the first index (0-based from ones place) where the given sum's digit differs from the actual sum's digit. Discuss edge cases like no difference (return -1), negative numbers (if allowed), and numbers of different lengths.

2. Choose an approach

Decide between computing the actual sum and comparing digits, or performing digit-by-digit addition with carry to avoid large number overflow. For most interviews, computing the sum is simpler and sufficient unless numbers are extremely large.

3. Implement digit extraction and comparison

Loop while either num1, num2, or sum has remaining digits. At each index, extract the current digit of sum and the current digit of the actual sum (by adding corresponding digits of num1 and num2 plus carry). Compare and return index if they differ.

4. Handle carry and termination

Update carry after each digit addition. Continue until all numbers are exhausted. If no difference found, return -1. Ensure the loop covers the maximum length of the three numbers.

5. Test with examples and analyze complexity

Walk through examples like num1=123, num2=456, sum=579 (returns -1) and num1=123, num2=456, sum=589 (returns 1). State time complexity O(max(log num1, log num2, log sum)) and space O(1).

Key Points to Mention

  • Digit extraction using modulo 10 and integer division by 10.
  • Handling carry propagation when adding digits.
  • Edge cases: no difference, different number lengths, negative numbers (if applicable).
  • Time and space complexity analysis.
  • Alternative approach: convert numbers to strings for easier digit access (but note potential leading zeros).
  • Clarify assumptions: non-negative integers, sum provided may be incorrect.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.