Leetcode Problems Randomised Algorithm