java solution
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```\nclass Solution {\n    public int longestSquareStreak(int[] nums) {\n        Arrays.sort(nums);\n        Map<Integer,Integer> m=new HashMap<>();\n        int res=-1;\n        for(int x:nums){\n            int perfect=(int)Math.sqrt(x);\n            //check perfect int or not as there may be int which will not form perfect square\n            \n            if(perfect*perfect==x && m.containsKey(perfect)){\n                m.put(x,m.get(perfect)+1);\n                res=Math.max((m.get(perfect)+1),res);   \n            }\n            else{\n                m.put(x,1);\n            }\n        }  \n        return res;\n    }\n}\n```
['Java']