Motorola Solutions interview question

They asked me to solve a problem on leetcode