Panda Guru LogoPanda
Guru

Wayfair Whiteboard Coding Practice

Round 1

Questions: This is a common Wayfair coding interview question that requires handling large integer addition using strings. The problem requires handling commas, carry propagation, and edge cases like invalid characters.

Question

Given two non-negative integers, num1 and num2 represented as strings, return the sum of num1 and num2 as a string. You must not use any built-in library for handling large integers (such as BigInteger) and must not convert the inputs to integers directly.

Example 1

Input: num1 = "11", num2 = "123" Output: "134"

Example 2

Input: num1 = "456", num2 = "77" Output: "533"

Example 3

Input: num1 = "0", num2 = "0" Output: "0"

Constraints

Candidate's Approach

The candidate implemented a method to add two large numbers represented as strings. The approach involved iterating through the strings from the end to the beginning, handling carry propagation, and ignoring commas. The candidate also implemented additional requirements to format the output with commas and handle invalid characters by throwing exceptions.

Interviewer's Feedback

The interviewer appreciated the candidate's implementation and attention to edge cases. They suggested further optimization for handling very large inputs and discussed potential improvements in code readability.