Leetcode brush inscription (16) - binary sum

Topics requirements:

Given two binary string, and return to their (expressed in binary).

And a non-empty input string contains only numeric  1 and  0.

answer:

See the whole idea of ​​the problem are: (1) complement: string up into short and long string of the same length; (2) transfer: the string to an integer array; (3) plus: each and adding bits, a full binary; (4) reverse: an array of integers, and then added into a string finished;

But write code super trouble, needs to be improved:

 

 

 

 

 

 Read the solution to a problem in the idea, really improved a lot, the above ideas can omit several steps: emphasis Ascii coding value can not convert the string to an array of integers, the direct use of characters, kneeling kneeling .. ..

Guess you like

Origin www.cnblogs.com/wangjm63/p/11519378.html