This is a random quick sort algorithm with an intention to count the length-1 of every subarray during the recursion.
The original instruction was given as