✅ [Python/C++] extract square root till death
\u2705 IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.\n*\n\n*Python.\n\nclass Solution:\n    def longestSquareStreak(self, nums: List[int]) -> int:\n        \n      
**\u2705 IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.**\n****\n\n**Python.**\n```\nclass Solution:\n    def longestSquareStreak(self, nums: List[int]) -> int:\n        \n        sqr = Counter(sorted(set(nums)))\n        \n        for n in sqr:\n            while (s:=isqrt(n))**2 == n and s in sqr:\n                sqr[s] += 1\n                n = s\n\n        return c if (c:=max(sqr.values())) >= 2 else -1\n```\n\n**C++.**\n```\nclass Solution \n{\npublic:\n    int longestSquareStreak(vector<int>& nums) \n    {\n        auto isqrt = [](int n) { return (int)floor(sqrt(n)); };\n        \n        sort(nums.begin(), nums.end());\n        nums.erase(unique(nums.begin(), nums.end()), nums.end());\n        \n        int s, c = 0;\n        unordered_map<int,int> sqr;\n        \n        for (int n : nums)\n        {\n            sqr[n] = 1;\n            while ((s = isqrt(n)) && s*s == n && sqr.count(s))\n                sqr[s] += 1, n = s;\n        }\n        \n        for (auto[n,s] : sqr) c = max(c,s);\n        return c > 1 ? c : -1;\n    }\n};\n```
[]