#3519

Count Numbers with Non-Decreasing Digits

master · 1760 · lc hard +32 · 38.5% accepted · 53 likes · top 17%

Description

Given string-encoded integers l and r and a base b, count how many integers in [l, r] have non-decreasing digits in base b (each digit >= the previous one, most significant to least).

Return the count modulo 109 + 7.

Code

1
2
3