Is there a way to can optimize the algo to O(Log n). Given a List check if records exists between the items. If no records exists then drop the item.
sample code:
l1 = [A,B,C,D]
foreach item1 in l1:
foreach item2 in l1:
is_exist=funcCheckRecordsExists(item1,item2)
So if no records exists for item (A,B) then no records exists between (B,A) as well. so when I have element items as (B,A) it should skip the function call.
is it possible to reduce the time complexity from O(n*n) to O(log n)?