FastPrepCount Analogous Arrays
Problems/Count Analogous Arrays

Count Analogous Arrays

Atlassian logoAtlassian● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Atlassian full-time online assessment. The report shows the whole problem. Our version is about 99% the same as the reported question.

A secret integer array is represented by the differences between consecutive values. For an analogous array a, every value must lie in the inclusive interval [lowerBound, upperBound], and for every valid i, a[i] - a[i + 1] = consecutiveDifference[i].

Return the number of analogous arrays. Return 0 when no starting value can keep the entire array inside the interval.

Function

countAnalogousArrays(consecutiveDifference: int[], lowerBound: int, upperBound: int) → int

Examples

Example 1

consecutiveDifference = [-2,-1,-2,5]lowerBound = 3upperBound = 10return = 3

The valid arrays are [3,5,6,8,3], [4,6,7,9,4], and [5,7,8,10,5].

Constraints

  • 0 <= consecutiveDifference.length <= 100000
  • -10^9 <= consecutiveDifference[i] <= 10^9
  • -10^9 <= lowerBound <= upperBound <= 10^9
  • The answer fits a signed int.

More Atlassian Online Assessment questions

  • Planning ProductionOA · Seen Feb 2025
  • K-Means ClusteringOA · Seen Feb 2025
  • Minimum Sorted Erasure OperationsOA · Seen Jun 2024
  • Get Maximum ScoreOA · Seen Mar 2024
  • Better Compression 🦀OA · Seen Mar 2024
  • Romanizer 🐡OA · Seen Mar 2024
  • Flower Bouquets 💐OA · Seen Mar 2024
  • Binary Search Tree IteratorOA · Seen Nov 2023
  • Binary Tree Level Order TraversalOA · Seen Nov 2023
  • Design HashMapOA · Seen Nov 2023

Similar questions at other companies

  • Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
  • Count Attack Vectors by Divisor RangeVisa · OAVisa interview questions
  • Prefix Scores With the Running MaximumC3.ai · OAC3.ai interview questions
  • Online No-Intercept Linear RegressionTwo Sigma · OATwo Sigma interview questions
  • Array Challenge (QR Intern)Akuna Capital · OAAkuna Capital interview questions
  • Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Random Pick with Weight Using Recorded DrawsAmazon · ONSITE INTERVIEW
  • Multinomial Sampling with Distribution ChecksNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
  • Random Pick with Weight Using Recorded DrawsMeta · PHONE SCREENMeta interview questions
  • Longest Stationary Sensor IntervalWayve · PHONE SCREEN

Atlassian interview experiences

  • Atlassian MLE Phone Screen: Model Deployment Design: 1 Experience
  • Atlassian Coding Screens and Karat: 3 Experiences (Part 2 of 2)
  • Atlassian Full Stack Interviews: 11 Experiences (Part 1 of 2)
All Atlassian interview questionsSee Atlassian hiring insights
Saved
class Solution {
    public int countAnalogousArrays(int[] consecutiveDifference, int lowerBound, int upperBound) {
      // Write your code here.
    }

}
Checking account…