Tap here to switch tabs
Problem
Submissions

Problem: Numbers At Most N Given Digit Set

med
30 min
Try to solve the Numbers At Most N Given Digit Set problem.

Statement

Given an array of strings digits representing a sorted set of unique digits, and an integer n, return the count of positive integers that can be generated using only digits from digits such that each generated integer is less than or equal to n.

Digits from digits may be reused any number of times when constructing an integer.

Constraints:

  • 1≤1 \leq digits.length ≤9\leq 9

  • digits[i].length =1= 1

  • digits[i] is a digit from $'1'$ to $'9'$

  • All the values in digits are unique

  • digits is sorted in nondecreasing order

  • 1≤1 \leq n ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Numbers At Most N Given Digit Set

med
30 min
Try to solve the Numbers At Most N Given Digit Set problem.

Statement

Given an array of strings digits representing a sorted set of unique digits, and an integer n, return the count of positive integers that can be generated using only digits from digits such that each generated integer is less than or equal to n.

Digits from digits may be reused any number of times when constructing an integer.

Constraints:

  • 1≤1 \leq digits.length ≤9\leq 9

  • digits[i].length =1= 1

  • digits[i] is a digit from $'1'$ to $'9'$

  • All the values in digits are unique

  • digits is sorted in nondecreasing order

  • 1≤1 \leq n ≤109\leq 10^9