leetcode 43 字符串相乘 multiply-strings【ct】

 ====

思路:

1 声明数组长度为num1.length+num2.length

2 取到各自的i和j位,求sum值为 res[i+j+1] + multiply

3 res[i+j+1] 为 sum %10

4 res[i+j] 为 res[i+j] + Math.floor(sum /10)

  (记住这个特定算法)

5 将res join起来,将前面的'0' 处理为''

6 如果结果是''返回0 ,否则返回结果

 

posted @ 2023-06-17 17:41  hh9515  阅读(9)  评论(0)    收藏  举报