计数
class Solution {
public:
int busyStudent(vector<int>& startTime, vector<int>& endTime, int queryTime) {
int n=startTime.size();
int ans=0;
for(int i=0;i<n;i++){
if(queryTime>=startTime[i]&&queryTime<=endTime[i]){
ans++;
}
}
return ans;
}
};
排序
class Solution {
public:
string arrangeWords(string text) {
stringstream ss(text);
vector<string> set;
string tmp;
while(getline(ss,tmp,' ')){
transform(tmp.begin(),tmp.end(),tmp.begin(),::tolower);
set.push_back(tmp);
}
stable_sort(set.begin(),set.end(),[](const string& s1,const string& s2){return s1.size()<s2.size();});
string ans=set[0];
ans[0]=ans[0]-'a'+'A';
for(int i=1;i<set.size();i++){
ans+=" "+set[i];
}
return ans;
}
};