Beat 100% O[nlogn] space complexity O[n]
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```cpp []\nclass Solution {\npublic:\n    int longestSquareStreak(vector<int>& nums) {\n     unordered_map<int,int>container;\n     sort(nums.begin(),nums.end());\n     int rtrn = -1;\n     for(auto n : nums)\n     {   \n        int root = sqrt(n);\n        //there is a problem comes eg: for n = 36,37 the value of root comes 6 \n        //thus we must need cross check\n        if(root*root==n && container.find(root)!=container.end())\n        {\n            container[n]=container[root]+1;\n            rtrn = max(rtrn , container[n]);\n        }\n        else  container[n]=1;\n     }   \n     return rtrn;\n    }\n};\n```
['C++']