StripeSoftware Engineer · Take-home ProjectCodemia practiceOptimize inversion for streaming input
Given a streaming input of integers, implement an algorithm to efficiently count the number of inversions in the data as it arrives, where an inversion is defined as a pair of indices (i, j) such that i < j and arr[i] > arr[j]. Your solution should optimize for time complexity and handle the input in a single pass, outputting the total count of inversions once the stream ends.
Medium
Coding & Algorithms