LogicMonitor interview question

pretty easy to medium leet code questions