Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

Finding Unique values in two ArrayLists

For Example A = [10010,10020,99948] and each element of A List possible values are atmost two values or one element or null.

you can take below is B list, 10010 = []. --> expected output is 10010 10020 =[10020,10020] -> expected output is null 99948 = [99948,99948] -> expected output is null

so final output should be 10010.

MyCode is working fine but i need better solution below the O(n).

var list = new ArrayList()
for ( val in A){
   var B = val.Valus.toList()
   if ( not B.contain(val)){
       list.add(val)
    }
}

Here output is : 10010

if A has 2000+ values it performance down , can be do better?

❌
❌