use a stack to maintain the increasing value index
use duplicate node to store the random pointer
compare the element in the array and find first element not increasing
add an if to check if the duplicated element has been visited