3754. 连接非零数字并乘以其数字和 I
Chunbin Lv4

https://leetcode.cn/problems/concatenate-non-zero-digits-and-multiply-by-sum-i/description/?envType=daily-question&envId=2026-07-06

比较简单,直接做

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function sumAndMultiply(n: number): number {
// 转成字符串,遍历去掉 0
const str = String(n)

// 相加
let sum = 0
let x = ""
for(let i = 0; i < str.length ;i++){
if(str[i]!=="0"){
sum += Number(str[i])
x += str[i]
}
}

return sum * Number(x)
};
 评论
评论插件加载失败
正在加载评论插件
由 Hexo 驱动 & 主题 Keep
访客数 访问量