Thanks for the post! I need, however, to point out that the solution for finding an intersection array (#8) not quite correct. Try to find an intersection array for these two arrays using your solution:
[1, 1, 1, 2, 1, 3, 4, 2, 2, 2, 2, 2, 2, 2, 2, 4, 5, 6], [2, 2, 2, 1, 1, 6, 7, 8, 2, 2, 2, 2]
the output is [ 1, 2, 6 ] when actually it supposed to be [ 1, 1, 2, 2, 2, 2, 2, 2, 2, 6 ] (sorted version)
[ 1, 2, 6 ]
[ 1, 1, 2, 2, 2, 2, 2, 2, 2, 6 ]
The Set does not work well to find a proper intersection array.
Set
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the post! I need, however, to point out that the solution for finding an intersection array (#8) not quite correct. Try to find an intersection array for these two arrays using your solution:
the output is
[ 1, 2, 6 ]
when actually it supposed to be[ 1, 1, 2, 2, 2, 2, 2, 2, 2, 6 ]
(sorted version)The
Set
does not work well to find a proper intersection array.