Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 524 Bytes

File metadata and controls

19 lines (14 loc) · 524 Bytes

Problem 20: Chaos Tracker

Problem Statement

Given an array arr, we say that two elements arr[i] and arr[j] form an inversion if arr[i] > arr[j] and i < j. Find the total number of inversions in the array.

Input Format

  • An array of integers arr.

Output Format

  • An integer representing the inversion count.

Constraints

  • 1 <= arr.length <= 10^5
  • 1 <= arr[i] <= 10^6

Example

Input: arr = [2, 4, 1, 3, 5]
Output: 3
Explanation: The inversions are (2, 1), (4, 1), and (4, 3).