携程笔试题第二

#include <iostream>
#include <vector>
#include <numeric>
#include <limits>

using namespace std;

//携程笔试题
/*请完成下面这个函数,实现题目要求的功能
当然,你也可以不按照下面这个模板来作答,完全按照自己的想法来 ^-^
******************************开始写代码******************************/
//流水线,已经排列好了顺序,所以不需要再进行排序
int calcMinStaff(vector<string> str,int m){
    int res=m,start=0,end=0,savedata;
    for (int i = 0; i < m; ++i) {
        string te= str[i];
        int len=te.size();
        string a,b;
        int pos=te.find(',');
        a=te.substr(0,pos);
        b=te.substr(pos+1,len-pos);
        start=stoi(a);
        end=stoi(b);
        if(i==0){
            savedata=end;
        }
        else if(savedata<=start&&i>0){
            savedata=end;
            res--;
        }

    }
    return res;
}

//
int main() {
    int m;
    cin>>m;
    vector<string> str;//输入
    for (int i = 0; i <m; ++i) {
        string k;
        cin>>k;
        str.push_back(k);
    }
    int res = calcMinStaff(str,m);
    cout << res << endl;
    return 0;

}

#研发笔试##携程##笔试题目#
全部评论
携程今年也是前面有 20 道选择题吗?
点赞 回复 分享
发布于 2020-05-06 18:36

相关推荐

钱嘛数字而已:辅导员肯定不能同意,不然你出事了,他要承担责任。但是,脚和脑子都长在你自己身上,使用它还需要向辅导员报告么? 辅导员必须按流程拒绝你,然后你拿出成年人的态度,做自己的选择。
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务