adspace


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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain parent-child context setup. How does it work? What are the advantages?

875


What is latest version of ios?

867


In a single model, can I have few entities in one sqlite db file and remaining in another sqlite db file?

990


Why do all model object attributes get marked with @dynamic and not synthesised? What does @dynamic mean?

850


What's the latest version of ios?

977


What are the different store migration options? How do they work?

879


What is the purpose of reuseidentifier?

920


What is latest ios version?

1003


What is dependency management tools?

877


What are transient properties?

925


What is nsmanagedobjectcontext? What are the different concurrency types? Explain them.

832


Why do all model object attributes get marked with @dynamic and not synthesised?

976


How to handle concurrency problems in core data?

1017


What is latest xcode version?

920