Without Whitespaces
Updated
Problem statement
You are given integers n, c, and k, together with a decimal digit string s of length n.
Count how many arrays of nonnegative integers could have produced s when their usual decimal representations were printed consecutively without separators. Every array element must be no greater than c, and no element may have a leading zero except for the value 0 itself.
The array may contain any positive number of elements. Return the number of valid arrays modulo 10^k.
Function
countArrays(n: int, c: long, k: int, s: String) → longExamples
Example 1
n = 7c = 1234567k = 9s = "1234567"return = 64There are 64 valid ways to split the seven-digit string into one or more values no greater than 1234567. The result remains 64 modulo 10^9.
Example 2
n = 2c = 12k = 3s = "12"return = 2The two valid arrays are [12] and [1, 2].
Constraints
1 ≤ n = s.length ≤ 10^41 ≤ c ≤ 10^91 ≤ k ≤ 18scontains only decimal digits.
More Postman interview questions
- Configuration SystemOA · Seen Sep 2020
- Large ResponsesOA · Seen Sep 2020
- Minimum Swaps to Sort an ArrayOA · Seen Aug 2020
- Validate IP AddressOA · Seen Aug 2020
- Maximum Laptop Rating in a Price RangeOA · Seen Aug 2019
- Group Duplicate Files by ContentONSITE INTERVIEW · Seen Feb 2026
- Encode and Decode a String StreamONSITE INTERVIEW · Seen May 2024
Similar questions at other companies
- String Transformation (Also for Infra Automation Intern)Snowflake · OASnowflake interview questions
- Sum of All ValuesFlexport · OAFlexport interview questions
- Count Vowel Strings With Follow RulesC3.ai · OAC3.ai interview questions
- Largest Minus Smallest Value of a Parenthesized ExpressionNutanix · ONSITE INTERVIEWNutanix interview questions
- Lexicographically Smallest Grid Path with One Letter ChangeInfosys · OAInfosys interview questions
- Minimum Merge ConflictsAmazon · OA
- Maximum Signal Walk in a Server TreeTower Research Capital · OA
- Balance a Chemical EquationMicrosoft · OAMicrosoft interview questions
- Binary CircuitAkuna Capital · OAAkuna Capital interview questions
- Jump Game with Prime-3 StepsUber · OAUber interview questions