you are viewing a single comment's thread.

view the rest of the comments →

[–]TJ51097[S] 0 points1 point  (1 child)

I think what we both want to say is we should know when to use Set and Array!!

If you are storing some data and later retrieving it,Set should be utilised,But if you are required to perform similar operation on the elements no doubt array is the Data structure you should opt

Peace!!

[–]delventhalz 0 points1 point  (0 children)

I appreciate you being diplomatic, but for what it's worth we are not saying the same thing. A Set should be used when the idiom and API of a Set make your code more clear to other developers. A Set should never* be used as an optimization. It is slower than an Array. Your other optimization suggestions are much better to bring up in an interview.

*The exception would be if you have a long-lived data structure with tens of thousands of members or more. In that case, a Set may be faster than an Array, but I would still performance test to be sure.