How will you implement sets and the intersection operation? Complexity?



How will you implement sets and the intersection operation? Complexity?..

Answer / Vikas Kumar Tyagi

In Swift, sets are implemented using `Set` data type. To find the intersection of two sets, you can simply use the `intersection(_:)` method.nComplexity: Adding an element to a set takes O(1) time, while finding the intersection takes O(min(n, m)) time, where n and m are the number of elements in both sets.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Apple iOS Interview Questions

Explain about Viewcontroller lifecycle.

1 Answers  


How would you create your own custom view in iOS operating system?

1 Answers   TryTechnicals Pvt Ltd,


What is nsuserdefaults?

1 Answers  


Can you please explain the difference between nsarray and nsmutablearray?

1 Answers  


What is the difference between retain & assign in iOS operating system?

1 Answers   B-Ways TecnoSoft,


What is nsmanagedobjectmodel?

1 Answers  


What is a delegate xcode?

1 Answers  


How are non-atomic and atomic properties different? Which one is the default property for synthesized properties?

1 Answers  


What is mvvm in ios swift?

1 Answers  


What is main thread checker?

1 Answers  


What is @implementation?

1 Answers  


Flow of push notification?

1 Answers  


Categories