HackWithInfy 2022

Revision en1, by prithwiraj15, 2022-03-15 21:22:46

This question appeared on HackWithInfy-2022

Problem Statement

You are given an array of length N containing a permutation of first N natual numbers i.e (1 to N). You are able to apply the following operation at most once. - Choose any subarray of size K and reverse it.

Return the minimum inversions in the array after said operations.

Inversion in an array is defined as a pair of indices (i,j) such that Ai > Aj and i < j.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English prithwiraj15 2022-03-15 21:41:46 796 Tiny change: 'st once.\n- Choose' -> 'st once.\n\n- Choose' (published)
en1 English prithwiraj15 2022-03-15 21:22:46 461 Initial revision (saved to drafts)