My Blog List

[Leetcode Solution] Add Binary

Analysis 

  • Each time add one digit from A and the corresponding digit from B. Save the carry and remainder. Store the remainder to result string

Note

  • Two input string might be in different size thus at the addition procedure, only add the digit that the string still has to the result
  • After all the addition, the carry might be 1. At this time add one more digit at the head of the result to handle it

Code


No comments:

Post a Comment

Enter you comment