Guidewire interview question

normal leetcode (easy - medium)