P19990 [GeeksforGeeks] Count numbers containing 43022
普及-
题目描述

Count the numbers between 1 to N containing 4 as a digit.

Example 1:
Input:
N = 9
Output:
1
Explanation:
4 is the only number between 1 to 9
which contains 4 as a digit.
Example 2:
Input:
N = 14
Output:
2
Explanation:
4 and 14 are the only number between 1
to 14 that contains 4 as a digit.

Your Task:
You don't need to read input or print anything. Your task is to complete the function countNumberswith4() which takes an Integer N as input and returns the answer.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Constraints:
1 <= N <= 10^{5}

输入格式

见题面

输出格式

见题面

样例输入
N = 9
样例输出
1