must see || easy to understand || binary search
do binary serach for every element of the array and find its square; \ntime complexcity of binary serach is log(n);\nbinary search for every n elements is n*log
do binary serach for every element of the array and find its square; \ntime complexcity of binary serach is log(n);\nbinary search for every n elements is n*log(n);\n\n# Code\n```\nclass Solution \n{\npublic:\n    int longestSquareStreak(vector<int>& nums) {\n        \n         int ans = -1;\n         sort(nums.begin(),nums.end());\n         for(int i=0;i<nums.size();i++)\n         {\n              long long int num = nums[i];\n              long long int pwr = num*num;\n              long long int len = 1;\n\n              while(binary_search(nums.begin(),nums.end(),pwr) == true)\n              {\n                   len++;\n                   long long int ele = pwr;\n                   pwr = ele *  ele;\n              }\n             if(len!=1 and len > ans)\n             ans = len;\n         }\n         return ans;\n    }\n};\n```
['Array', 'Binary Search', 'Dynamic Programming', 'Sorting', 'C++']