easy solution | java clean code ✅
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int longestSquareStreak(int[] nums) {\n        Arrays.sort(nums);\n        int [] arr = new int[100001];\n        int maxi = 0;\n        for(int i: nums)\n        {\n            int root = (int)Math.sqrt(i);\n            if(root * root != i) arr[i] = 1; //no predecessor\n            else arr[i] = arr[root] + 1; // extend streak from root\n            maxi = Math.max(maxi, arr[i]);\n        }\n        if(maxi == 1) return -1;\n        else return maxi;\n    }\n}\n```
['Array', 'Sorting', 'Java']