BruteForce. Straight forward solution. Time complexity O(nlogn). Space complexity…

» DEV Community | dev.to