• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
July 18, 2023 |1.9K Views
Inversion of Array - SDE Sheet
Description
Discussion

In this videos, we will discuss the problems Count Inversion.

For an array, inversion count indicates how far (or close) the array is from being sorted. If array is already sorted then the inversion count is 0. If an array is sorted in the reverse order then the inversion count is the maximum. 
Formally, two elements a[i] and a[j] form an inversion if a[i] > a[j] and i < j.

For Example: 
Input: N = 5, arr[] = {2, 4, 1, 3, 5}
Output: 3
Explanation: The sequence 2, 4, 1, 3, 5 has three inversions (2, 1), (4, 1), (4, 3).

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-

Article: https://www.geeksforgeeks.org/inversion-count-in-array-using-merge-sort/
Problem: https://practice.geeksforgeeks.org/problems/inversion-of-array-1587115620/1
SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More