Tap here to switch tabs
Problem
Submissions

Problem: Count Numbers with Non-Decreasing Digits

med
30 min
Try to solve the Count Numbers with Non-Decreasing Digits problem.

Statement

Given two positive integers l and r represented as strings in base 1010, along with an integer b, return the total count of integers in the inclusive range [l,r][l, r] whose base bb representation consists of nondecreasing digits.

A base bb representation has nondecreasing digits if every digit from left to right is greater than or equal to the digit before it.

Constraints:

  • 1≤1 \leq l.length ≤\leq r.length ≤100\leq 100

  • 2≤2 \leq b ≤10\leq 10

  • l and r consist only of digits.

  • The value represented by l is less than or equal to the value represented by r.

  • l and r do not contain leading zeros.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Numbers with Non-Decreasing Digits

med
30 min
Try to solve the Count Numbers with Non-Decreasing Digits problem.

Statement

Given two positive integers l and r represented as strings in base 1010, along with an integer b, return the total count of integers in the inclusive range [l,r][l, r] whose base bb representation consists of nondecreasing digits.

A base bb representation has nondecreasing digits if every digit from left to right is greater than or equal to the digit before it.

Constraints:

  • 1≤1 \leq l.length ≤\leq r.length ≤100\leq 100

  • 2≤2 \leq b ≤10\leq 10

  • l and r consist only of digits.

  • The value represented by l is less than or equal to the value represented by r.

  • l and r do not contain leading zeros.