#腾讯音乐秋招# #腾讯音乐求职进展汇总# 求大佬们看看第二题和第三题我写的有什么问题,第二题50, 第三题202:ListNode* mergeList(ListNode* a, ListNode* b) { ListNode* dummy = new ListNode(-1); ListNode* cura = a, *curb = b, *p = dummy; while(cura && cura->val == curb->val) { p->next = cura; cura = cura->next; curb = curb->next; p = p->next; } ListNode* fast = cura, *slow = curb; int n = 0, m = 0; while(cura) { ++n; cura = cura->next; } while(curb) { ++m; curb = curb->next; } int len = n - m; if(n ListNode* tmp = fast; fast = slow; slow = tmp; len = m - n; } while(len-- && fast) { fast = fast->next; } while(fast && fast->val != slow->val) { fast = fast->next; slow = slow->next; } p->next = fast; return dummy->next; }3:int matrixCount(vector& a, int val) { int n = a.size(); vector> r(n + 1, vector(n + 1, 0)); vector> e(n + 1, vector(n + 1, 0)); vector> d(n + 1, vector(n + 1, 0)); for(int i = 1; i for(int j = 1; j if(a[i - 1][j - 1] == 'r') { r[i][j] = r[i - 1][j] + r[i][j - 1] - r[i - 1][j - 1] + 1; e[i][j] = e[i - 1][j] + e[i][j - 1] - e[i - 1][j - 1]; d[i][j] = d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1]; } else if(a[i - 1][j - 1] == 'e') { r[i][j] = r[i - 1][j] + r[i][j - 1] - r[i - 1][j - 1]; e[i][j] = e[i - 1][j] + e[i][j - 1] - e[i - 1][j - 1] + 1; d[i][j] = d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1]; } else { r[i][j] = r[i - 1][j] + r[i][j - 1] - r[i - 1][j - 1]; e[i][j] = e[i - 1][j] + e[i][j - 1] - e[i - 1][j - 1]; d[i][j] = d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1] + 1; } } } long long res = 0; for(int k = 1; k for(int i = 1; i + k - 1 for(int j = 1; j + k - 1 int x = i + k - 1, y = j + k - 1; long long numa = 0, nume = 0, numd = 0; numa = r[x][y] - r[x - k][y] - r[x][y - k] + r[x-k][y-k]; nume = e[x][y] - e[x - k][y] - e[x][y - k] + e[x-k][y-k]; numd = d[x][y] - d[x - k][y] - d[x][y - k] + d[x-k][y-k]; long long sum = min(numa, min(numd, nume)); if(sum >= val) ++res; } } } return res; }