TheAlmostLuckyNumbersDivTwo
SRM 510 · 2010-11-01 · by Vasyl[alphacom]
SRM 510 · 2010-11-01 · by Vasyl[alphacom] · Simple Search, Iteration
Problem Statement
Problem Statement
John and Brus believe that the digits 4 and 7 are lucky and all others are not. According to them, an almost lucky number is a number that contains at most one non-lucky digit in its decimal representation. Return the total number of almost lucky numbers between a and b, inclusive.
Constraints
- a will be between 1 and 1,000,000, inclusive.
- b will be between a and 1,000,000, inclusive.
Examples
0)
4 7 Returns: 4
All numbers between 4 and 7 are almost lucky.
1)
8 19 Returns: 4
Numbers 8, 9, 14 and 17 are almost lucky.
2)
28 33 Returns: 0
No almost lucky numbers here.
3)
1234 4321 Returns: 36
4)
64 86 Returns: 13
Submissions are judged against all 66 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class TheAlmostLuckyNumbersDivTwo with a public method int find(int a, int b) · 66 test cases · 2 s / 256 MB per case