Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <vector>
- using namespace std;
- bool change(string a, string b)
- {
- for(int i = 0 ; i < min(a.size(), b.size()); ++i)
- {
- if(a[i] > b[i])
- return true;
- if(a[i] < b[i])
- return false;
- }
- if(a.size() > b.size())
- return true;
- return false;
- }
- class AnnoyingColleague
- {
- public:
- string getColleague(vector<string> names, vector<string> availability)
- {
- for(int i = 0 ; i < names.size() ; ++i)
- {
- for(int j = i+1 ; j < names.size() ; ++j)
- {
- if(change(names[i],names[j]))
- {
- swap(names[i],names[j]);
- swap(availability[i],availability[j]);
- }
- }
- }
- for(int i = 0 ; i < availability.size() ; ++i)
- if(availability[i] == "available")
- return names[i];
- return "none";
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement