Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of Powerful Integers

Count the Number of Powerful Integers asks you to count values in an inclusive range whose digits do not exceed a limit and whose decimal representation ends with a given string.

Statement

You are given three positive integers start, finish, and limit. You are also given a string s representing a positive integer.

An integer is defined as powerful if it satisfies both of the following conditions:

  • Every digit of the integer is at most limit.

  • The integer ends with the suffix s.

Return the number of powerful integers in the inclusive range [[start, finish]].

Constraints:

  • 1≤1 \leq start ≤\leq finish ≤1015\leq 10^{15}

  • 1≤1 \leq limit ≤9\leq 9

  • 1≤1 \leq s.length ≤⌊log⁡10(\leq \lfloor \log_{10}(finish)⌋+1) \rfloor + 1

  • s consists only of numeric digits that are at most limit.

  • s does not contain leading zeros.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of Powerful Integers

Count the Number of Powerful Integers asks you to count values in an inclusive range whose digits do not exceed a limit and whose decimal representation ends with a given string.

Statement

You are given three positive integers start, finish, and limit. You are also given a string s representing a positive integer.

An integer is defined as powerful if it satisfies both of the following conditions:

  • Every digit of the integer is at most limit.

  • The integer ends with the suffix s.

Return the number of powerful integers in the inclusive range [[start, finish]].

Constraints:

  • 1≤1 \leq start ≤\leq finish ≤1015\leq 10^{15}

  • 1≤1 \leq limit ≤9\leq 9

  • 1≤1 \leq s.length ≤⌊log⁡10(\leq \lfloor \log_{10}(finish)⌋+1) \rfloor + 1

  • s consists only of numeric digits that are at most limit.

  • s does not contain leading zeros.