FastPrepClassify a Number Series and Return the Next Term
Problems/Classify a Number Series and Return the Next Term

Classify a Number Series and Return the Next Term

InMobi logoInMobi● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an InMobi full-time online assessment. The report does not say which class wins when ranges overlap, the details of the geometric ratio, or the limits on the numbers. Our version is about 92% the same as the reported question.

Given an integer array sequence, decide whether it follows an arithmetic progression, an integer-ratio geometric progression, or a Fibonacci-style progression. Return the next term. If it follows none of them, return -999.

Classification Rules

  1. First test for an arithmetic progression: every consecutive difference must be equal.
  2. If that test fails, test for a geometric progression: there must be one integer multiplier r such that sequence[i] = sequence[i - 1] * r for every valid i.
  3. If both earlier tests fail, test for a Fibonacci-style progression: sequence[i] = sequence[i - 1] + sequence[i - 2] for every i >= 2. The first two terms may be any integers.

Run the tests in the order above. If a sequence fits more than one rule, the first rule that fits decides the answer.

Function

nextSeriesNumber(sequence: long[]) → long

Examples

Example 1

sequence = [2,5,8,11]return = 14

The consecutive difference is always 3, so this is an arithmetic progression and the next term is 11 + 3 = 14.

Example 2

sequence = [3,6,12,24]return = 48

Each term is the previous term multiplied by 2, so the next term is 48.

Example 3

sequence = [8,9,17,26]return = 43

Each term from the third onward is the sum of the previous two, so the next term is 17 + 26 = 43.

Example 4

sequence = [1,2,4,7]return = -999

The sequence satisfies none of the three progression rules, so the sentinel -999 is returned.

Constraints

  • 3 <= sequence.length <= 1000
  • -10^9 <= sequence[i] <= 10^9
  • Every multiplication, addition, difference, and valid next term fits in a signed long.

More InMobi Online Assessment questions

  • Validate a Bracket SequenceOA · Seen Oct 2026
  • Count Substrings Matching with One Adjacent SwapOA · Seen Oct 2026
  • Maximum Subarray with Start and End WindowsOA · Seen Oct 2026
  • Minimum Service Cold StartsOA · Seen Oct 2026
  • Range Maximum Subarray Sum QueriesOA · Seen Oct 2026
  • Connected Components with Divisor ThresholdOA · Seen Aug 2026
  • Maximize Impression ValueOA · Seen Aug 2026
  • Supply Path OptimizationOA · Seen Aug 2026
  • Delivery ServiceOA · Seen Jun 2026
  • Shared InterestOA · Seen Jun 2026

Similar questions at other companies

  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
  • Costliest ChocolateRippling · OARippling interview questions
  • Online No-Intercept Linear RegressionTwo Sigma · OATwo Sigma interview questions
  • Plus Mult ArrayIBM · OAIBM interview questions
  • Progressive Tax CalculatorInteractive Brokers · OA
  • 2020 Account Balance with Monthly Card FeesDRW · OADRW interview questions
  • Array Challenge (QR Intern)Akuna Capital · OAAkuna Capital interview questions
  • Latency Bucket CounterDatadog · OA · PHONE SCREENDatadog interview questions
  • First Fibonacci Number at Least the Array SumBitGo · OABitGo interview questions
All InMobi interview questionsSee InMobi hiring insights
Saved
class Solution {
    public long nextSeriesNumber(long[] sequence) {
        // write your code here
    }
}
Checking account…