leetcode 415. Add Strings
来源:互联网 发布:mac桌面图标怎么隐藏 编辑:程序博客网 时间:2024/04/30 01:40
class Solution {public: string addStrings(string num1, string num2) { string &a =num1; string &b = num2; if(a.length() < b.length()) swap(a,b); int x1 = a.length()-1,x2 = b.length()-1; for(;x2 >= 0 ;x1--,x2--){ a[x1] = b[x2] + a[x1] - '0'; if(x1 > 0 && a[x1] > '9'){ a[x1-1]++; a[x1] -= 10; } } while(x1 > 0){ if(a[x1] > '9'){ a[x1] -= 10; a[x1-1]++; } else break; x1--; } if(a[0] > '9'){ a[0] = a[0] - 10; a = '1'+a; } return a; }};
0 0
- Leetcode-415. Add Strings
- LeetCode 415. Add Strings
- [LeetCode]--415. Add Strings
- LeetCode 415. Add Strings
- LeetCode 415. Add Strings
- LeetCode 415. Add Strings
- leetcode 415. Add Strings
- 【LeetCode】 415. Add Strings
- LeetCode 415. Add Strings
- Leetcode 415. Add Strings
- LeetCode - 415. Add Strings
- LeetCode 415. Add Strings
- Leetcode 415. Add Strings
- Leetcode-415. Add Strings
- LeetCode-415. Add Strings
- leetcode 415. Add Strings
- [leetcode]415. Add Strings
- 【Leetcode】415. Add Strings
- leetcode(35).121. Best Time to Buy and Sell Stock
- Android中RecyclerView刷新
- FatFs源码剖析
- Redhat 6.2(64位) 及 Oracle 11.2.0.4(64位)安装随笔
- caffe如何自定义网络以及自定义层(python)(五)
- leetcode 415. Add Strings
- C# 跨线程调用控件
- SSD1实验报告——Lab2.2
- 第十三周项目1-Prim算法的验证
- ANDROID STUDIO安卓插架失效的问题
- JAVA 解析未知JSON并获得key,value,value的类型
- 学习php微信开发应用接入API接口笔记
- word2vec
- 总结