Intuit Interview Question

Leetcode pirates and thieves question