FastPrepTriangular Range Increments
Problems/Triangular Range Increments

Triangular Range Increments

IMC Trading logoIMC Trading● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an IMC Trading online assessment. Our task is about 95% the same as the report. We use the corrected decreasing pattern. The report left out limits on the queries and values, so we set them.

You are given starting values and a list of queries [i,v]. Indices start at zero.

Each query adds a triangle-shaped bump to the array. For every valid position j, it adds max(v - abs(j-i), 0). The amount drops by one for each step away from i. On each side it stops at the end of the array or when the amount reaches zero.

Return the final array after all queries. Use signed 64-bit values for the result.

Function

applyTriangularUpdates(values: int[], queries: int[][]) → long[]

Examples

Example 1

values = [0,0,0,0,0,0,0,0,0]queries = [[3,5]]return = [2,3,4,5,4,3,2,1,0]

The array starts as all zeros. The query adds five at the fourth position and one less for each step away from it, in both directions, until the array ends. The result is [2,3,4,5,4,3,2,1,0].

Example 2

values = [2,0,1]queries = [[0,2],[2,3]]return = [5,3,4]

The first query adds two to position zero, one to position one, and nothing to position two. The second query adds three to the last position, two to the middle one, and one to the first. Each bump is cut off at the ends of the array. Adding both bumps to the starting values gives the final array.

Constraints

  • 1 <= values.length <= 10^5
  • 0 <= queries.length <= 10^5
  • 0 <= values[j] <= 10^9
  • Each query contains [i,v], with 0 <= i < values.length and 1 <= v <= 10^9.

More IMC Trading Online Assessment questions

  • Earliest Meeting Start on a 24-Hour ClockOA · Seen Nov 2026
  • Grid Paths with Override PassesOA · Seen Oct 2026
  • Weighted LFU CacheOA · Seen Sep 2026
  • Rock JumpingOA · Seen Aug 2026
  • Stack Batch RemovalOA · Seen Aug 2026
  • Chain of CommandOA · Seen Aug 2026
  • Choose ContainersOA · Seen Aug 2026
  • Sub-matrix SumsOA · Seen Jul 2026
  • Sub-matrix SumsOA · Seen Jul 2026
  • Can Every Package Fit in a BoxOA · Seen Jul 2026

Similar questions at other companies

  • Count Lamps Lighting Each PointAirbnb · OAAirbnb interview questions
  • Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
  • Most Visited Sprint MarkerMicrosoft · OAMicrosoft interview questions
  • Split a Matrix Into Four Partitions by Average (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Earliest Time to Schedule a MeetingMathWorks · OAMathWorks interview questions
  • Calculate the Sum After Range TogglesBlink Health · OA
  • Optimal TransferSnowflake · OASnowflake interview questions
  • Count Attack Vectors by Divisor RangeVisa · OAVisa interview questions
  • Smallest Most-Lit Street PositionHudson River Trading · OAHudson River Trading interview questions
  • Most Visited Sprint MarkerChubb · OAChubb interview questions

Interview reports that mention this question

  • IMC Trading OA: What It Tests (2026)

IMC Trading interview experiences

  • IMC Trading SWE OA and Video: 18 Experiences (Part 3 of 3)
  • IMC Trading SWE OA Questions: 22 Experiences (Part 2 of 3)
  • IMC SWE New Grad OA and Interviews: 58 Experiences (Part 1 of 3)
All IMC Trading interview questionsSee IMC Trading hiring insights
Saved
class Solution {
    public long[] applyTriangularUpdates(int[] values, int[][] queries) {
        // Write your solution here.
    }
}
Checking account…