Check if 2 arrays are similar without hashing or sorting

后端 未结 4 1065
南旧
南旧 2021-01-13 10:20

We need to check if 2 arrays are similar or not. The elements can be duplicate as well. For example A = {2,3,4,5,6,6} and B = {3,6,2,4,6,5} are similar.

I have a nai

4条回答
  •  余生分开走
    2021-01-13 10:37

    A = {2,3,4, 5,-1,6} and B = {3,6,2,4,6,5}

    you should add break in your if-statement, without it your code will work only is there is no duplicates

提交回复
热议问题