intlongestPalindrome(string s){int hash[128]={0};for(constauto& ch : s){
hash[ch]++;}int ret =0;for(constauto& x : hash){
ret += x /2*2;// 奇偶混合处理}return ret < s.size()? ret +1: ret;}
intfindContentChildren(vector<int>& g, vector<int>& s){sort(g.begin(), g.end());sort(s.begin(), s.end());int ret =0, n = g.size(), m = s.size();for(int i =0, j =0; i < n && j < m; i++, j++){while(j < m && s[j]< g[i]){
j++;}if(j < m){
ret++;}}return ret;}
string optimalDivision(vector<int>& nums){int n = nums.size();if(n ==1){returnto_string(nums[0]);}if(n ==2){returnto_string(nums[0])+"/"+to_string(nums[1]);}
string ret =to_string(nums[0])+"/("+to_string(nums[1]);for(int i =2; i < n; i++){
ret +="/"+to_string(nums[i]);}
ret +=")";return ret;}
intjump(vector<int>& nums){int left =0, right =0, maxPos =0, ret =0, n = nums.size();while(left <= right){if(maxPos >= n -1){return ret;}// 遍历当前层,更新下一层最右端点for(int i = left; i <= right; i++){
maxPos =max(maxPos, nums[i]+ i);}
left = right +1;
right = maxPos;
ret++;}return-1;// 跳不到的情况}