Sort squares of a sorted array in linear runtime (O(n))

Given a sorted array that contains both negative and positive integers we aim to get its squares array in sorted orders. Let us understand this with an example. Let’s understand how we can solve this problem in linear time. To solve this in linear time, we have to take two handles which represent the startRead More »


Shuffle an integer array

Shuffling is a procedure to randomize the input values by swapping back and forth. In this article, we aim to rearrange the input integer array uniquely. Let’s see an example step by step approach. Step by step approach Firstly, we pick a random index below size-1 (by skipping the last item) and tries to swapRead More »