Meta Variant for Add Strings (LC415)
Company: Meta
Role: unknown
Interview Stage: Onsite
Location: unknown
Year: unknown
Original Post Content:
Hey y’all! Hope all is well. Here’s another solution for another frequently asked Meta question, Leetcode 415 Add Strings and its variant.
From what I’ve seen, the OG is never asked directly. Rather, Meta will ask a variant where the given number strings can also have decimals. Because of this, there are many edgecases to consider:
1. What if both numbers have decimals?
2. What if only one number has decimals?
3. What if neither has decimals?
4. What if the number of decimal places differ between the two numbers?
5. What if there’s a carry from adding the decimal parts?
6. What if there’s a carry from adding the most significant digits of the whole numbers?
…There’s a lot of things to keep in mind sooo I made a comment on this post with a bunch of different testcases.
Check it out (or not!):
https://www.youtube.com/watch?v=0JucNk5VPEQ
---
Reference to the OG LC problem: https://leetcode.com/problems/add-strings/description/
Good luck on your phone screens & onsite loops.