Very easy code|| Easy to understand
Intuition\nFirstly store all the elements in an unordered set .\nSort the elements.\nIncreasing the value if we find the square of a number in the set.\n Descri
# Intuition\nFirstly store all the elements in an unordered set .\nSort the elements.\nIncreasing the value if we find the square of a number in the set.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n<!-- # Approach -->\n<!-- Describe your approach to solving the problem. -->\n\n<!-- # Complexity -->\n<!-- - Time complexity: -->\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n<!-- - Space complexity: -->\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int longestSquareStreak(vector<int>& nums) {\n        int res=0;\n        unordered_set<long long> st;\n        for(int i=0;i<nums.size();i++){\n            st.insert(nums[i]);\n        }\n        sort(nums.begin(),nums.end());\n        for(int i=0;i<nums.size();i++){\n            int temp=1;\n            long long a=nums[i];\n            int cnt=1;\n            while(cnt<nums.size() && st.find(a*a)!=st.end()){\n                cnt++;\n                a=a*a;\n                temp++;\n                // if(cnt==nums.size())\n                // return max(temp,res);\n            }\n            // if()\n            res=max(res,temp);\n        }\n        if(res<2)\n        return -1;\n        return res;\n    }\n};\n```
['C++']