100% fast | Simple short code with easy explanation
Intuition\n Describe your first thoughts on how to solve this problem. \nThink of playing chess rounds like taking steps. Every 15 minutes, a new round starts. 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThink of playing chess rounds like taking steps. Every 15 minutes, a new round starts. The code takes your start and end times, and it figures out how many steps you took in terms of these 15-minute rounds:\n-> It checks when you started and stopped.\n-> If you played through midnight, it adds extra steps for the time after midnight.\n-> If you didn\'t start right at the beginning of a round, it moves you to the next round\'s starting point.\n-> Then, it simply counts the steps you took between your start and end.\n\n---\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- **Convert Time to Minutes:**\nThe minConvert function takes a time string (like "hh:mm") and converts it to the equivalent number of minutes in a day.\n\n- **Calculate Rounds Played:**\nIn the numberOfRounds function, we convert both login and logout times to minutes using minConvert.\n\n- **Adjust for Next Day:**\nIf the login time is later than the logout time, it means we\'ve played across midnight. So, we add 24 hours\' worth of minutes (1440) to the logout time.\n\n- **Round to Nearest 15 Minutes:**\nIf the login time is not at a 15-minute mark, we round it up to the next 15-minute interval.\n\n- **Calculate Rounds:**\nWe find the absolute difference between logout and login times and divide it by 15. This gives us the number of 15-minute rounds played.\n\n- **Return the Result:**\nThe calculated number of rounds played is the answer we return\n\n# Complexity\n- Time complexity: $$O(1)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minConvert(string &time){\n        return stoi(time.substr(0,2))*60 + stoi(time.substr(3,2));\n    }\n\n    int numberOfRounds(string loginTime, string logoutTime) {\n        int start = minConvert(loginTime), end = minConvert(logoutTime);\n\n        if (start > end) end += 1440;\n        if (start % 15) start=(start/15 + 1)*15;\n        \n        return abs(end - start)/15; \n    }\n};\n```
['Math', 'C++']