Current interview question

leetcode question. normal question for finance companies