Advertisement
add1ctus

100

Mar 13th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <string>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. bool change(string a, string b)
  6. {
  7. for(int i = 0 ; i < min(a.size(), b.size()); ++i)
  8. {
  9. if(a[i] > b[i])
  10. return true;
  11. if(a[i] < b[i])
  12. return false;
  13. }
  14. if(a.size() > b.size())
  15. return true;
  16. return false;
  17. }
  18.  
  19. class AnnoyingColleague
  20. {
  21. public:
  22. string getColleague(vector<string> names, vector<string> availability)
  23. {
  24. for(int i = 0 ; i < names.size() ; ++i)
  25. {
  26. for(int j = i+1 ; j < names.size() ; ++j)
  27. {
  28. if(change(names[i],names[j]))
  29. {
  30. swap(names[i],names[j]);
  31. swap(availability[i],availability[j]);
  32. }
  33. }
  34. }
  35. for(int i = 0 ; i < availability.size() ; ++i)
  36. if(availability[i] == "available")
  37. return names[i];
  38. return "none";
  39. }
  40. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement