[removed] efficiently compare two integer arrays

后端 未结 6 1310
庸人自扰
庸人自扰 2020-12-30 03:14

I have two integer arrays which contain numeric values. I want to look through both lists and check for commonality (or lack of) between the lists. I.e. I want to iterate th

6条回答
  •  青春惊慌失措
    2020-12-30 03:49

    When using two nested loops the complexity will be O(n*n). Sorting both array can be done in complexity O(n log n).

    AS Marcelo Cantos stated duck-waddle :) through both in paralell has complexity O(n) leading to an overall complexity of O(n log n) + O(n) which is O (n log n).

提交回复
热议问题