Solve animals-and-legs count | SIG (Susquehanna) Interview Question