Sort, map setup then check square and calculate result... <<< EASY TO UNDERSTAND >>>
Intuition\n1. Initially we find square streak in a list of numbers, where each number in a streak is the square of the previous number. \n2. Looking at the prob
# Intuition\n1. Initially we find square streak in a list of numbers, where each number in a streak is the square of the previous number. \n2. Looking at the problem, one might realize that if we can store and reference each square root\'s streak length, we can build up streaks efficiently by iterating over a sorted list of numbers.\n\n# Approach\n1. Sort the Array\n2. Initialize a Map\n3. Iterate Through Numbers\n4. Track the Longest Streak\n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(n)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int longestSquareStreak(vector<int>& nums) {\n        map<int, int>a;\n        sort(nums.begin(), nums.end());\n        int r = -1;\n        for(int n: nums) {\n            int sq = sqrt(n);\n            if(sq*sq == n && a.find(sq)!=a.end()) {\n                a[n] = a[sq]+1;\n                r = max(r, a[n]);\n            } else a[n] = 1;\n        }\n        return r;\n    }\n};\n```
['Array', 'Hash Table', 'Dynamic Programming', 'Sorting', 'C++']