1 ~ n an integer number of 1 appearing

1: Title Description

Enter an integer n, n ~ 1 seek the n represents an integer of decimal number 1 appears.

For example, these input 12,1 to 12 contain the digital integer of 1 and 12, 1, 10, 11 have appeared in a total of 5 times.

 

Example 1:

Input: n = 12
Output: 5
Example 2:

Input: n = 13
Output: 6
 

limit:

1 <= n < 2^31

Source: stay button (LeetCode)
link: https: //leetcode-cn.com/problems/1nzheng-shu-zhong-1chu-xian-de-ci-shu-lcof
copyrighted by deduction from all networks. Commercial reprint please contact the authorized official, non-commercial reprint please indicate the source.

2: Title Analysis

3: Code Example

Guess you like

Origin www.cnblogs.com/dazhu123/p/12591956.html