simple and easy C++ solution || Hash Table
if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n###### Let\'s Connect on Linkedin: www.linkedin.com/in/shishirrsiam\n\n\n\n# Code\ncpp []\nclass Solution {\
# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n###### Let\'s Connect on Linkedin: www.linkedin.com/in/shishirrsiam\n\n\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int longestSquareStreak(vector<int>& nums) \n    {\n        set<int>st;\n        int maxValue = 1e5 + 5;\n        unordered_set<int>values(begin(nums), end(nums));\n        for(int i = 1; i * i <= maxValue; i++)\n        {\n            if(values.count(i)) st.insert(i);\n            if(values.count(i * i)) st.insert(i * i);\n        }\n\n        vector<int>store(begin(st), end(st));\n        int ans = 1, count = 1, n = store.size();\n\n        for(int i = 0; i < n; i++)\n        {\n            count = 1;\n            int val = store[i];\n            for(int j = i + 1; j < n; j++)\n            {\n                if((long(val) * val) > 2e5) break;\n                if(val * val == store[j])\n                {\n                    count += 1;\n                    val = store[j];\n                }\n            }\n            ans = max(ans, count);\n        }\n\n        return ans == 1 ? -1 : ans;\n    }\n};\n```
['Array', 'Hash Table', 'Dynamic Programming', 'Sorting', 'C++']