FastPrepConfiguration System
Problems/Configuration System

Configuration System

Postman logoPostman● HardFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Postman online assessment. The images in the report keep the rule for generating the data, the rule for counting ordered pairs, the constraints, and the sample. Our version is about 99% the same as the reported question.

A building company offers wall side lengths from a strictly increasing sequence s. Generate n lengths beginning with s[0] = s0. For each 1 ≤ i < n:

s[i] = ((k * s[i - 1] + b) mod m) + 1 + s[i - 1].

A rectangular house configuration chooses an ordered pair of offered lengths (s[i], s[j]). The ceiling is painted for free when s[i] * s[j] ≤ a.

Return the number of ordered configurations that qualify. Because orientation matters, (x, y) and (y, x) are counted separately when x != y.

Function

variantsCount(n: int, s0: int, k: int, b: int, m: int, a: long) → long

Examples

Example 1

n = 3s0 = 1k = 1b = 1m = 2a = 4return = 6

The generated lengths are [1, 2, 4]. The qualifying ordered pairs are (1,1), (1,2), (1,4), (2,1), (2,2), and (4,1).

Example 2

n = 1s0 = 2k = 3b = 4m = 5a = 3return = 0

The only configuration has area 2 * 2 = 4, which is greater than 3.

Constraints

  • 1 ≤ n ≤ 6 × 10^7
  • 1 ≤ s[i] ≤ 10^9 for every generated value.
  • 1 ≤ k, b, m ≤ 10^9
  • 1 ≤ a ≤ 10^18
  • The answer fits in a signed 64-bit integer.

More Postman interview questions

  • Large ResponsesOA · Seen Sep 2020
  • Minimum Swaps to Sort an ArrayOA · Seen Aug 2020
  • Validate IP AddressOA · Seen Aug 2020
  • Without WhitespacesOA · Seen Sep 2019
  • 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

  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Collect Branches for a Bird NestVisa · OAVisa interview questions
  • Score Difference When Even Picks Reverse the ListMicrosoft · OAMicrosoft interview questions
  • Match OutcomesAdobe · OAAdobe interview questions
  • Rotate the Box and Drop the StonesZipRecruiter · OAZipRecruiter interview questions
  • Candy Crush Grid Matching and GravityRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Alternate Positive and Negative ValuesTesla · ONSITE INTERVIEWTesla interview questions
  • Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
  • Nested List Iterator with RemoveAirbnb · PHONE SCREENAirbnb interview questions
  • Sum Two Piecewise-Constant Time SeriesGoogle · ONSITE INTERVIEWGoogle interview questions
All Postman interview questionsSee Postman hiring insights
Saved
class Solution {
    public long variantsCount(int n, int s0, int k, int b, int m, long a) {
        // write your code here
    }
}
Checking account…