The very first cyclic problem is not working for the test case.
Input: 5 2 1 2 5 1
Result: 1 2 5 2 5 1
If all of the elements contains duplicates
Cyclic Sort Method:
public static void sort(int[] nums) {
int i = 0;
while (i < nums.length) {
int j = nums[i] - 1;
if (nums[i] != nums[j])
swap(nums, i, j);
else
i++;
}
}