剑指 Offer 43. 1~n 整数中 1 出现的次数bahttps://leetcode.cn/problems/1nzheng-shu-zhong-1chu-xian-de-ci-shu-lcof/
| 2023-9-23
0  |  阅读时长 0 分钟
Date
Mar 30, 2023
need_review
need_review
type
剑指 Offer(第 2 版)
undo
undo
难度
困难
输入一个整数 n ,求1~n这n个整数的十进制表示中1出现的次数。
例如,输入12,1~12这些整数中包含1 的数字有1、10、11和12,1一共出现了5次。
示例 1:
示例 2:
限制:
  • 1 <= n < 2^31
注意:本题与主站 233 题相同:https://leetcode-cn.com/problems/number-of-digit-one/

 
  • Giscus
目录