With approach will be better in performance ``` v...
# announcements
s
With approach will be better in performance
Copy code
val objects = LinkedList<SomeCommonObject>()
fun calledMultipleTimes(){
 val someObject = getNotUniqueObject() //This object will be next unique for each 10k calls
 objects.add(someObject)
}

fun calledOnce(){
 objects.distinct().forEach { it.doSometingLikeNone() }
}
Or
Copy code
val objects = LinkedList<SomeCommonObject>()
fun calledMultipleTimes(){
 val someObject = getNotUniqueObject() //This object will be next unique for each 10k calls
 if(someObject !in objects)
   objects.add(someObject)
}

fun calledOnce(){
 objects.forEach { it.doSometingLikeNone() }
}
Checked, answer is 2