Problem Solving Patterns
Source: JavaScript Algorithms and Data Structures Masterclass Frequency Counter When counting frequency of iterable objects, avoid nested looping that results in O(n^2), by using objects or sets to collect values.
Example Create a function named “same” that compares 2 arrays, and check if one array contains the squared values of the other, with matching frequencies
The Naive Solution Use nested loop to check if squared value of current looping element exists.