Java | Simple DP 1 pass
Intuition\nStore the numbers we\'ve seen in a hash map as the key, and the length of the increasing subsequence as value.\n\nAt any value x we check if sqrt(x) 
# Intuition\nStore the numbers we\'ve seen in a hash map as the key, and the length of the increasing subsequence as value.\n\nAt any value `x` we check if `sqrt(x)` is in the map, if it is, we add map[sqrt(x)] to our current subsequence length, otherwise there is no streak and we set `map[x]` to 1.\n\n# Code\n```\nclass Solution {\n    public int longestSquareStreak(int[] nums) {\n        Arrays.sort(nums);\n        Map<Integer, Integer> squareStreak = new HashMap<>();\n        int best = -1;\n\n        for (int x : nums) {\n            double sqrt = Math.pow(x, 0.5);\n            if (sqrt % 1 == 0 && squareStreak.containsKey((int) sqrt)) {\n                squareStreak.put(x, squareStreak.get((int) sqrt) + 1);\n                best = Math.max(best, squareStreak.get(x));\n            } else {\n                squareStreak.put(x, 1);\n            }\n        }\n\n        return best;\n    }\n}\n```
['Java']