Company: Gartner_10march
Difficulty: medium
Index Sort Problem Description You are given an array A of size N , which contains a permutation of the numbers from 1 to N . To sort the array in ascending order, you must perform the following operations: Choose an integer K from the range [1, N] . Select two different indices i and j (both not equal to K ) and swap the elements at those indices. You can perform this swap operation multiple times, but K remains fixed throughout the sorting process. Your task is to find and return an integer value, representing the count of distinct values of K from 1 to N that allow you to transform the given array into sorted order using the above operations. Note: Assume 1-based indexing. Input Specification input1: An integer value N , representing size of the array A . input2: An integer array A . Output Specification Return an integer value, representing the count of distinct values of K from 1 to N that allow you to transform the given array into sorted order using the above operations. Example