• + 0 comments

    ur method uses recursion and is definitely at least O(n^2), i cant be bothered to figure out the exact time of this recursion, but note that the brute force method is O(n^2).

    furthermore, there are issues with ur possible_ans, ur creating a local storage in each call stack, not a global storage and passing it by reference during recursion.

    the question wants O(n)

    if u had no time out its because the test cases are weak

    look at my method, its O(n)