Try to search your question here, if you can't find : Ask Any Question Now ?

Is Set.has() method O(1) and Array.indexOf O(n)?

HomeCategory: stackoverflowIs Set.has() method O(1) and Array.indexOf O(n)?
sourav asked 2 weeks ago

I have seen in an answer that Set.has() method is O(1) and Array.indexOf() method is O(n).

var a = [1, 2, 3, 4, 5];
a.indexOf(5);          


s = new Set(a);
s.has(5);              //Is this O(1)?

Is Set.has() really O(1) ?

1 Answers
Best Answer
Mikhail answered 2 weeks ago
Your Answer

11 + 9 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com