C++ || Using Map
\n\n# Code\n\nclass Solution {\npublic:\n    int longestSquareStreak(vector<int>& nums) \n    {\n        map<long long,long long> mp;\n        int n = nums.size
\n\n# Code\n```\nclass Solution {\npublic:\n    int longestSquareStreak(vector<int>& nums) \n    {\n        map<long long,long long> mp;\n        int n = nums.size();\n        \n        for(auto it : nums)\n        {\n            mp[it]++;\n        }\n        \n        int mx = -1;\n        bool flag = false;\n        for(auto it : mp)\n        {\n            long long curr = it.first*it.first;\n            int cnt = 1;\n            while(mp.count(curr)==1)\n            {\n                cout<<curr<<" ";\n                flag = true;\n                cnt++;\n                curr = curr*curr;\n            }\n            \n            mx = max(cnt,mx);\n        }\n        \n        if(!flag) return -1;\n        \n        return mx;\n    }\n};\n```
['C++']