C solution
Solution\nGood day, let\u2019s tease our brain.\n\nSo the problem asks us to find the maxinum subsequence that does not necessarily need to be adjacent. Moreove
# Solution\nGood day, let\u2019s tease our brain.\n\nSo the problem asks us to find the maxinum subsequence that does not necessarily need to be adjacent. Moreover, the task is to find the given value exist or not. Given these information, fearing that there may be some testcases full of 2, or 1, we shirnk the given nums into a set.\n\nNext, we sort the set, and iterate through every element within. Starting from a given position, we find the maximu strak length we cam obtain from it. The halting condition should be:\n\n1. the square of the current value does not exist in the given set\n2. the current value is greater than the root of the maxmum value $10^5$\n\nAnd for each halting situation, we record the maximum length, compare it to the final answer.\n# Code\n```c []\n#define maxN 100005\n\nint max(int a, int b) { return a > b ? a : b; }\n\nint cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }\n\nint biSearch(int *arr, int n, int target) {\n    int left = 0;\n    int right = n - 1;\n    while (left <= right) {\n        int mid = left + (right - left) / 2;\n        if (arr[mid] == target) {\n            return mid;\n        } else if (arr[mid] < target) {\n            left = mid + 1;\n        } else {\n            right = mid - 1;\n        }\n    }\n    return -1;\n}\n\nint longestSquareStreak(int *nums, int numsSize) {\n    int seen[maxN] = {0};\n    int *set = (int *)malloc(maxN * sizeof(int));\n    int setidx = 0;\n    for (int i = 0; i < numsSize; i++) {\n        if (!seen[nums[i]]) {\n            seen[nums[i]] = 1;\n            set[setidx++] = nums[i];\n        } else {\n            continue;\n        }\n    }\n    qsort(set, setidx, sizeof(int), cmp);\n    int ans = -1;\n    for (int i = 0; i < setidx; i++) {\n        int curr = set[i];\n        if (curr >= 400) {\n            continue;\n        }\n        int big = curr * curr;\n        int currRes = -1;\n        while (biSearch(set, setidx, big) != -1) {\n            if (currRes == -1) {\n                currRes = 2;\n            } else {\n                currRes++;\n            }\n            curr = big;\n            if (curr >= 400) {\n                break;\n            }\n            big = curr * curr;\n            // printf("curr = %d, big = %d\\n", curr, big);\n        }\n        ans = max(ans, currRes);\n    }\n    return ans;\n}\n\n```
['C']