[HackerRank] Preparation_Kit (08. Minimum Swaps 2) [Array]
You are given an unordered array consisting of consecutive integers ∈ [1, 2, 3, ..., n] without any duplicates. You are allowed to swap any two elements. Find the minimum number of swaps required to sort the array in ascending order.Examplearr = [7, 1, 3, 2, 4, 5, 6]Perform the following steps:i arr swap (indices)0 [7, 1, 3, 2, 4, 5, 6] swap (0,3)1 [2, 1, 3, 7, 4,..
[HackerRank] Preparation_Kit (06. Left Rotation) [Array]
A left rotation operation on an array shifts each of the array's elements 1 unit to the left. For example, if 2 left rotations are performed on array [1, 2, 3, 4, 5], then the array would become [3, 4, 5, 6, 7]. Note that the lowest index item moves to the highest index in a rotation. This is called a circular array.Given an array a of n integers and a number, d, perform d left rotations on the ..