摘要:
Given a number represented as an array of digits, plus one to the number.思考:大数相加的思想。flag是进位标记。class Solution {public: vector plusOne(vector &digits) { int len=digits.size(); bool flag=false; digits[len-1]+=1; int i=len-1; if(digits[i]>9) flag=true; while(... 阅读全文
摘要:
Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100".思考:大数相加的思想。class Solution {public: string addBinary(string a, string b) { if(a.length()==0) return b; if(b.length()==0) return a; int len=a.length()0;i--) { ... 阅读全文