Time complexity: O(n+m)
Space complexity: O(n+m)
Runtime 0 ms Beats 100.00% of users with Java Memory 43.04 MB Beats 6.73% of users with Java