Header Ad

HackerEarth Little Kuldeep and contests problem solution

In this HackerEarth Little Kuldeep and contests problem solution Everyone who is involved with HackerEarth in whatsoever form knows who Little Kuldeep is. He's not so little, but he's called that. (No one knows why!) He's pretty efficient at organizing, mentoring, managing various hiring challenges, contests happening on HackerEarth all the time. But age has caught up with him, finally. He's turned into little, old Kuldeep from little Kuldeep.

Earlier, he could've handled multiple contests like a piece of cake, but it is not possible for him now. In the present scenario, he needs other people to moderate contests, because he's busy moderating some other contest that is happening at the same time.

Given the timings of the contests happening, can you check and tell little, old Kuldeep if he would need a moderator to help him out, or not?


HackerEarth Little Kuldeep and contests problem solution


HackerEarth Little Kuldeep and contests problem solution.

#include<bits/stdc++.h>

#define int long long int
#define pb push_back
#define f first
#define s second
#define all(x) x.begin() , x.end()
#define forn(n) for(int i=0;i<n;i++)
#define fork(k, n) for(int i=k;i<n;i++)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl "\n"
#define mod 1000000007

using namespace std;

struct Interval {
int start;
int end;
};

bool cmp(Interval a,Interval b)
{
if(a.start < b.start)
return true;
return false;
}

void solve() {
int n;
cin>>n;
Interval arr[n];
string s;
int start,end;
forn(n)
{
cin>>s;
start = stoi(s.substr(0,2))*60 + stoi(s.substr(3,2));
end = stoi(s.substr(6,2))*60 + stoi(s.substr(9,2));
arr[i] = { start , end };
}
sort(arr,arr+n,cmp);
//forn(n) cout<<arr[i].start<<" "<<arr[i].end<<" \n";
bool ok = true;
forn(n-1)
{
if(arr[i].end > arr[i+1].start )
{
ok = false;
break;
}
}
if(ok)
cout<<"Who needs a moderator?";
else
cout<<"Will need a moderator!";
return ;
}

signed main() {
fast;
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}

Post a Comment

0 Comments