Meta·Software Engineer·Onsite - Coding / Algorithms
- Given two non-negative integers as decimal strings, return their sum as a string without using any built-in big-integer libraries. Walk through the function signature, edge cases, example inputs and outputs, and time/space complexity.
- Design a weighted random city picker: given a list of city names and their populations, implement an init function and a pickCity function that returns each city with probability proportional to its population. Target O(n) preprocessing and O(log n) or better per pick. Also discuss how you'd validate randomness, avoid precision issues with large population totals, and support dynamic updates like insertions, deletions, and population changes.
“I've done grade-school addition in code before so the core loop wasn't the problem.”