9.21 FunPlus
选择题和编程题; 60min
1、反转链表;
2、给你两个数组,求最小的数组平方和;力扣链接,最后写了个垃圾代码就交了;
class Solution { public: long long minSumSquareDiff(vector<int>& nums1, vector<int>& nums2, int k1, int k2) { priority_queue<int> q; for(int i=0; i< nums1.size(); i++){ q.push(abs(nums1[i]-nums2[i])); } int k = k1+k2; while(k--> 0){ auto top = q.top(); q.pop(); if(top == 0) break; q.push(top-1); } long long ret = 0; while(!q.empty()){ ret += (long long)q.top() * q.top(); q.pop(); } return ret; } };