BAE Systems interview question

Solve a programming problem similar to LeetCode