leetcode415】的更多相关文章

题目描述: 解决思路: 此题较简单,和前面[LeetCode67]方法一样. Java代码: public class LeetCode415 { public static void main(String[] args) { String a="1",b="9"; System.out.println(a+"和"+b+"相加的结果是:"+new Solution().addStrings(a, b)); } } class…
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is < 5100. Both num1 and num2 contains only digits 0-9. Both num1 and num2 does not contain any leading zero.…
public class Solution { public string AddStrings(string num1, string num2) { //判断num1和num2的长度,进行对齐 if (num1.Length < num2.Length) { //将num1前补0 var zerocount = num2.Length - num1.Length; StringBuilder sb = new StringBuilder(); ; i < zerocount; i++) {…
题目描述: 解题思路: 此题的思路简单,下面的代码用StringBuilder更加简单,注意最后的结果要反转过来.[LeetCode415]Add Strings的解法和本题一模一样. java代码: public class LeetCode67 { public static void main(String[] args) { String a="11",b="1"; System.out.println(a+"和"+b+"相加的…