← Upstart Interview Insights

Upstart·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Did a technical screen for a software engineer role at Upstart. Just one coding problem, pretty short session, nothing too crazy but it required more careful thinking than I expected.

Questions Asked (1)

Q1

Write a function that takes an integer representing a number of bytes and returns a formatted string showing the value in the appropriate unit (B, KB, or MB) with two decimal places. 1 KB = 1024 B, 1 MB = 1024 KB.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Seemed straightforward but I fumbled the boundary conditions at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First clarify the expected behavior for edge cases like negative bytes and values less than 1 KB. Then implement a function that determines the appropriate unit by comparing the byte count against 1024 thresholds, and formats the result to two decimal places using string formatting. Discuss potential trade-offs such as using 1000 vs 1024 and how to handle rounding.

Pro tip: Mention that you would use integer division to determine the unit to avoid floating-point precision issues, and explicitly handle the case where bytes is exactly 1024 or 1048576 to ensure correct unit selection.

1. Clarify requirements and edge cases

Ask about handling negative inputs, zero, and values that are exactly at unit boundaries (e.g., 1024 bytes). Confirm whether to use 1024 or 1000 as the base and how to round (e.g., standard rounding vs. truncation).

2. Design the unit selection logic

Use conditional checks or a loop to determine the largest unit (B, KB, MB) such that the value is at least 1 in that unit. For example, if bytes >= 1024*1024, use MB; else if bytes >= 1024, use KB; else B.

3. Compute the converted value

Divide the byte count by the appropriate factor (1 for B, 1024 for KB, 1024*1024 for MB) to get the value in the chosen unit. Ensure the division is done as floating-point to preserve decimals.

4. Format the output string

Format the numeric value to exactly two decimal places using a method like sprintf, format, or f-strings, and append the unit symbol (e.g., '1.50 KB').

5. Test with representative cases

Walk through examples: 500 B, 1024 B, 1536 B, 1048576 B, and a large value like 5 MB. Verify that the output matches expectations and discuss any rounding behavior.

Key Points to Mention

  • Edge cases: zero, negative numbers, and exact boundaries (1024, 1048576)
  • Choice of base: 1024 (binary) vs 1000 (decimal) and why 1024 is specified
  • Rounding method: standard rounding vs truncation and its impact on displayed value
  • Floating-point precision: potential issues and how to mitigate (e.g., using integer math for unit selection)
  • Code clarity: using a loop or conditional chain for unit selection
  • Testing strategy: unit tests for boundary values and typical values

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