Easy C++ solution using hashmap
Intuition\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 
# Intuition\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```\nclass Solution {\npublic:\n    int longestSquareStreak(vector<int>& nums) {\n        sort(nums.begin() , nums.end() , greater<int>());\n        unordered_map<int , int> mp;\n\n        for(auto it: nums){\n            mp[it] = 1;\n        }\n        int count;\n        int maxi = -1;\n\n        for(int i=0 ; i<nums.size()-1 ; i++){\n            count = 1;\n            int x = nums[i];\n\n            while(mp[sqrt(x)]>0){\n                int t = sqrt(x);\n                if(t*t == x)\n                    count++;\n                else break;\n                mp[sqrt(x)]--;\n                x = sqrt(x);          \n            }\n            maxi = max(maxi , count);\n        }\n        return maxi==1?-1:maxi;\n    }\n};\n```
['C++']