FastPrepDifference Calculator (Akuna Shang Hai 🏙️)
Problems/Difference Calculator (Akuna Shang Hai 🏙️)

Difference Calculator (Akuna Shang Hai 🏙️)

Akuna Capital logoAkuna Capital● EasyFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Given an integer array arr, compute the absolute difference between two indicators.

Indicator 1

Split the array into maximal runs of equal values. Count a run when its value is k and its length is exactly k.

Indicator 2

For each positive integer k whose one-based index exists, inspect the array starting at one-based index k. Count k when exactly k consecutive copies of the value k begin there; the following value, if one exists, must differ from k.

Return the absolute difference between the two counts.

Function

difference_calculator(n: int, arr: int[]) → int

Examples

Example 1

n = 14arr = [3, 3, 2, 2, 5, 5, 5, 5, 5, 3, 3, 3, 2, 2]return = 3

Indicator 1 is 4: the qualifying maximal runs are two 2s, five 5s, three 3s, and the final two 2s. Indicator 2 is 1 because exactly five 5s begin at one-based index 5. The absolute difference is 3.

Example 2

n = 10arr = [1, 2, 2, 4, 4, 4, 4, 2, 2, 2]return = 0

Indicator 1 counts the runs of one 1, two 2s, and four 4s. Those same values also begin with their required lengths at one-based indices 1, 2, and 4, so Indicator 2 is also 3 and the result is 0.

Constraints

  • 1 <= n <= 100
  • n == arr.length
  • 1 <= arr[i] <= 15

More Akuna Capital interview questions

  • Last Digit of the Ways to Split Traders Between Two OfficesOA · Seen Dec 2026
  • Light Bulbs Left On After All Engineers FinishOA · Seen Dec 2026
  • Delivery Management SystemOA · Seen Nov 2026
  • Count Server ReplacementsOA · Seen Nov 2026
  • Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximum Remaining Drone PowerOA · Seen Nov 2026
  • Biased Coin: Probability of Exactly h HeadsPHONE SCREEN · Seen Nov 2026
  • Positive Nth Root with Gradient DescentPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Rolling MetricsOA · Seen Oct 2026
  • Vowel Substring GameOA · Seen Sep 2026

Similar questions at other companies

  • Theme Park Shuttle Wait TimeAirbnb · OAAirbnb interview questions
  • Macaron Order with Set DiscountsShopify · OAShopify interview questions
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Book Reading EveningsGoogle · OAGoogle interview questions
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Wind-Blown Leaves Remaining in a GridAbridge · OAAbridge interview questions
  • Lift Total TravelInfosys · OAInfosys interview questions
  • Shell Command Counts with History ReferencesTikTok · OATikTok interview questions
  • Count Dropped RequestsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Recursively Expanded Shell Command CountsHudson River Trading · OAHudson River Trading interview questions

Akuna Capital interview experiences

  • Akuna Capital Quant Trader and QR Interviews: 5 Experiences
  • Akuna Capital JQR CodePair Rounds: 8 Experiences (Part 6 of 6)
  • Akuna Capital QR Probability Phones: 14 Experiences (Part 5 of 6)
  • Akuna Capital QR-ML Interviews: 11 Experiences (Part 4 of 6)
  • Akuna Capital QR Regression Rounds: 11 Experiences (Part 3 of 6)
  • Akuna Capital QR Coding Interviews: 17 Experiences (Part 2 of 6)
All Akuna Capital interview questionsSee Akuna Capital hiring insights
Saved
class Solution {
    public int difference_calculator(int n, int[] arr) {
        // write your code here
    }

}
Checking account…