Caching the results

  • 0

    The problem itself is not hard. Here are some further thoughts and discussions we can think:

    1. 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.

    2. How to deal with the cases if zero input is allowed? A traditional followup question.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.