Basic Solution Time Complexity: O(Nlogn)
Code\npython3 []\nimport math\nclass Solution:\n    def longestSquareStreak(self, num: List[int]) -> int:\n        nums = list(set(num))\n        result = []\n 
# Code\n```python3 []\nimport math\nclass Solution:\n    def longestSquareStreak(self, num: List[int]) -> int:\n        nums = list(set(num))\n        result = []\n        for i in nums:\n            if i == math.isqrt(i) ** 2:\n                result.append(i)\n        total = 0\n        nums.sort()\n        num.sort()\n        result.sort()\n        for i in range(len(num)):\n            curr = result[:]\n            temp = num[i]\n            length = [temp]\n            while curr:\n                if curr[0] == temp * temp:\n                    length.append(curr.pop(0))\n                    temp = length[-1]\n                else:\n                    curr.pop(0)\n            if len(length) > 1:\n                total = max(total, len(length))\n        return total if total > 0 else -1\n\n```
['Python3']