C++ Solution || Easy Set Solution || Detailed Explanation
Intuition\nTo solve this problem, we need to find the longest streak of numbers in which each number is the square of the previous one. By converting the array 
# Intuition\nTo solve this problem, we need to find the longest streak of numbers in which each number is the square of the previous one. By converting the array to a set, we can use its properties to check if the square of a number exists in constant time, thereby efficiently counting streaks.\n\n# Approach\n1. Convert the array `nums` to a set, `st`, to quickly check the existence of elements and to avoid duplicates.\n2. Initialize `maxcnt` as `-1` to keep track of the longest streak found.\n3. **For each unique number in `st`**:\n    - Initialize `cnt` to count the length of the current streak.\n    - Repeatedly square the number and check if the squared number exists in `st`. If it does, increment `cnt`.\n4. If the streak length is at least 2, update `maxcnt` with the maximum streak length found.\n5. Return `maxcnt`, which will be the length of the longest square streak.\n\n# Complexity\n- Time complexity: $$O(nlogn)$$\n\n- Space complexity: $$O(n)$$ \n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int longestSquareStreak(vector<int>& nums) {\n        set<long long> st(nums.begin(), nums.end());\n        int maxcnt = -1;\n        for (auto num : st) {\n            int cnt = 0;\n            while (st.find(num) != st.end()) {\n                cnt++;\n                num *= num;\n            }\n\n            if (cnt >= 2) {\n                maxcnt = max(maxcnt, cnt);\n            }\n        }\n        return maxcnt;\n    }\n};\n```\n\n# Quote of the Day\n> ***Persevere through the small gains. The longest streaks are built by staying consistent and pushing forward.***\n\n![1721315779911.jpeg](https://assets.leetcode.com/users/images/0ffa7e77-af3f-4109-a901-c2117214502b_1730091317.4329803.jpeg)\n
['Array', 'Hash Table', 'C++']