Ad
  • Custom User Avatar

    Be careful with solutions like this because you are iterating through nums for each element of nums making it O(n^2) time complexity. This gets very slow as the size of nums grows. You can accomplish the same result by iterating through nums only once or twice. Obviously for these test cases nums isn't long enough to matter though.

    Cheers!