is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
I used Node.js to code the solution
Assumptions:
- The two strings have the same size (for simplicity). If they weren't, I would have padded the smaller number with zeros;
- The strings are made by 0 and 1 only;
- The symbol "0" is mapped as false, and "1" as true;
Approach:
- Transform both strings in array of characters
- Initialise the carry to "0"
- Scan the array and calculate the sum for between the elements of the two array plus the carry
- The sum is calculated using the XOR operator, while the carry using the AND operator.
- The implicit type coercion in JavaScript allows me to map strings to truthy/falsey values and calculate sum and carry with the boolean operators
Complexity
- O(n) in time and space
- Simone Spaccarotella January 20, 2021