Skip to content
Programmingoneonone
Programmingoneonone
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth Simon cannot sleep problem solution

YASH PAL, 31 July 202411 February 2026
In this HackerEarth Simon cannot sleep problem solution It’s 12 o’clock at midnight (00 : 00) and Simon cannot sleep! So he decided to stare at the clock on his wall until he falls asleep.
He saw the clock’s hands and got to thinking ‘How many times they’ll pass each other until I fall asleep’ hh : mm. Imagine that he fell asleep at . Now, you must figure out how many times clock’s hands overlap from 00 : 00 to hh : mm (including 00 : 00 and hh : mm).
hackerEarth Simon cannot sleep problem solution

hackerEarth Simon cannot sleep problem solution.


#include <bits/stdc++.h>

using namespace std;

int h, m;
char c;

int moji(int h, int m){
int p = m / 5;
int ans = h;
if(h >= 12)
h -= 12, ans--;
if(p > h) ans++;
else if (p == h){
if(m % 5 >= m / 12.0)
ans++;
}
return ans;
}

int ali(int h, int m){
int ans = h;
if(h >= 12)
h -= 12, ans--;
return ans + (11 * m >= h * 60);
}

int main(){
cin >> h >> c >> m;
cout << moji(h, m) << endl;

return 0;
}

second solution

h, m = map(int, input().split(':'))

print((m * 12 >= h % 12 * 60 + m) + (h if h < 12 else h - 1))
coding problems solutions HackerEarth HackerEarth

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes