Easy DP solution
Intuition\n- Create a DP hashmap to store the maximum streak up to the current number and contains the current number (e.g. [2, 4, 16] then dp[16] = 3).\n- For 
# Intuition\n- Create a DP hashmap to store the maximum streak up to the current number and contains the current number (e.g. [2, 4, 16] then dp[16] = 3).\n- For any number i, if its square root (sqrt) is already in the hashmap, its hash value will be DP[sqrt] + 1\n- Variable ans to keep track of the max so far.\n\n# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(n)\n# Code\n```python []\nclass Solution(object):\n    def longestSquareStreak(self, nums):\n        """\n        :type nums: List[int]\n        :rtype: int\n        """\n        nums.sort()\n        ans = 0\n        n = len(nums)\n        for i in range(len(nums)):\n            sqrt = math.sqrt(nums[i])\n            if sqrt in dp:\n                dp[nums[i]] = dp[sqrt]+1\n            else:\n                dp[nums[i]] = 1\n            ans = max(ans, dp[nums[i]])\n        if ans == 1:\n            return -1\n        return ans\n```
['Python']