Why use long long || Solving Overflow using int only !!
Overflow Solution : Since constraint is- 2 <= nums[i] <= 1e5\nSo finding squares of elements greater than 317 is useless.\n\n# Code\n\nclass Solution {\npublic:
Overflow Solution : Since constraint is- 2 <= nums[i] <= 1e5\nSo finding squares of elements greater than 317 is useless.\n\n# Code\n```\nclass Solution {\npublic:\n    int longestSquareStreak(vector<int>& nums) {\n       unordered_map<int, int>mp;\n       for(auto& it : nums) mp[it] = 1;\n       sort(begin(nums), end(nums));\n       int r = -1;\n       for(int i = 0; i < nums.size(); i++) {\n           if(nums[i] >= 317) break;\n           int cur = nums[i] * nums[i];\n           int cnt = 1;\n           while(mp[cur]) {\n               cnt++;\n               if(cur >= 317) break;\n               cur = cur *cur;\n           }\n           r = max(r, cnt);\n       }\n       return r == 1 ? -1 : r;\n    }\n};\n```
['C++']