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