JPMorganChase interview question

How to do a leetcode medium question