The problem itself is not hard. Here are some further thoughts and discussions we can think:
Each query may be O(N^2)? so caching the result would be a good option if there are multiple same queries in the list. Your interviewer can be impressed if you could mention that.
How to deal with the cases if zero input is allowed? A traditional followup question.