FastPrepWithout Whitespaces
Problems/Without Whitespaces

Without Whitespaces

Postman logoPostman● HardINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Postman intern online assessment. The image in the report shows the full counting rule, the constraints, and the sample. We added the function to write. Our version is about 99% the same as the reported question.

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) → long

Examples

Example 1

n = 7c = 1234567k = 9s = "1234567"return = 64

There 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 = 2

The two valid arrays are [12] and [1, 2].

Constraints

  • 1 ≤ n = s.length ≤ 10^4
  • 1 ≤ c ≤ 10^9
  • 1 ≤ k ≤ 18
  • s contains 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
All Postman interview questionsSee Postman hiring insights
Saved
class Solution {
    public long countArrays(int n, long c, int k, String s) {
        // write your code here
    }
}
Checking account…