Leetcode 大數運算 415 字串相加

2021-10-08 19:49:46 字數 426 閱讀 6865

num1 和num2 的長度都小於 5100

num1 和num2 都只包含數字 0-9

num1 和num2 都不包含任何前導零

你不能使用任何內建 biginteger 庫, 也不能直接將輸入的字串轉換為整數形式

= =把每日一題和標籤的題搞混了

不是用佇列做的

大數運算,兩數末尾和進製提出來相加,直至全部加完且沒有進製停止

class

solution

return s.

reverse()

.tostring()

;//對字串反轉

}}

官方解釋

string、stringbuffer和stringbuilder的區別

str.charat()和str[i]的區別

leetcode415 字串大數相加

given two non negative numbersnum1andnum2represented as string,return the sum ofnum1andnum2.note the length of bothnum1andnum2is 5100.bothnum1andnum2c...

leetcode415 字串大數相加

given two non negative numbersnum1andnum2represented as string,return the sum ofnum1andnum2.note the length of bothnum1andnum2is 5100.bothnum1andnum2c...

LeetCode 字串相加 415

給定兩個字串形式的非負整數 num1 和num2 計算它們的和。注意 num1 和num2 的長度都小於 5100.num1 和num2 都只包含數字 0 9.num1 和num2 都不包含任何前導零。你不能使用任何內建 biginteger 庫,也不能直接將輸入的字串轉換為整數形式。思路 先將字串...