Anduril interview question

One Leetcode medium problem and a follow up.