You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// The function have a hidden nested loop using filter() and includes() This makes it quite expensive for us
17
+
18
+
// Time Complexity
19
+
// .filter() does n operation and .includes() does m operation since it is a nested loop the time complexity would be the product of the two complexities
20
+
// O (n * m )
21
+
// Space Complexity
22
+
// .filter creates a temporary array to store common items O(n) space and "Set" also takes O(m) space. This is un avoidable if we use this nested loop
0 commit comments