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. Implement the function solve(N, A) that returns this count. Input Format The first line contains an integer N, the size of the array A. The second line contains N space-separated integers A[1], A[2], ..., A[N]. (inferred - the source passes N and A as function arguments; this line-based stdin layout is the harness for