Map Traversal || simple solution ||  c++
Just store the value in map and traverse to find the square\nUpvote if it was helpful\n\nclass Solution\n{\npublic:\n    int longestSquareStreak(vector<int> &nu
**Just store the value in map and traverse to find the square**\n**Upvote if it was helpful**\n```\nclass Solution\n{\npublic:\n    int longestSquareStreak(vector<int> &nums)\n    {\n        unordered_map<long long, long long> mp;\n        for (auto &it : nums)\n            mp[it]++;\n\n        int ans = INT_MIN;\n        for (auto &it : mp)\n        {\n            long long to_search = it.first;\n            int temp = 0;\n            while (mp.find(to_search) != mp.end())\n            {\n                if (mp.find(to_search) != mp.end())\n                {\n                    temp++;\n                    to_search = to_search * to_search;\n                }\n            }\n            ans = max(temp, ans);\n        }\n        if (ans == 1 || ans == 0)\n            return -1;\n        else\n            return ans;\n    }\n};\n```
['Interactive']