C solution for Longest Square Streak
Approach\nGiven a string of n integers, find the numbers which are in a streak where each number is the quare of the previous number.\nEg:- a={2,8,5,4,90,16}\nH
# Approach\nGiven a string of n integers, find the numbers which are in a streak where each number is the quare of the previous number.\nEg:- a={2,8,5,4,90,16}\nHere the streak is of 3 as after sorting {2,4,16} where each number is the sqaure of the previous number and there are only 3 such numbers present in the string given in the above example.\nThis is a very simple approach.\n\n# Complexity\n#### Time complexity\nO(logn)\n#### Space complexity: O(n)\nO(n)\n# PLEASE UPVOTE\n\n# Code\n```c []\nint cmp(const void* a, const void* b) {\n   return (*(int*)a < *(int*)b);\n}\n\nint longestSquareStreak(int* nums, int numsSize) {\n    int sqr[100001]={0};\n    int chk[317]={0};\n    bool exist[317]={0};\n    int n=0;\n    for (int i=0;i<numsSize;i++) {\n        if (nums[i]>316) { \n            sqr[nums[i]]=1;\n        }\n        else if (!exist[nums[i]]) { \n            //only keep one number of each as they can appear multiple time\n            chk[n++]=nums[i];\n            exist[nums[i]]=true;\n        }\n    }\n    int count=-1;\n    qsort(chk, n, sizeof(int), cmp);\n    for (int i=0;i<n;i++) {\n        sqr[chk[i]]=sqr[chk[i]*chk[i]]+1;\n        if (count<sqr[chk[i]]) {\n            count=sqr[chk[i]];\n        }\n      \n    }\n    return (count<=1) ? -1 : count;\n}\n```
['C']