Squarepoint Capital Interview Question

Live leetcode medium level question. Know how to analyze runtime