This is not a bad reasoning problem. I say 'reasoning' because, IMHO, the most valuable takeaway in a job interview would be to assess how the candidate approaches the problem and whether they can reason to find an algorithm to solve it. Actual code seems quite secondary after that.