EZ C O(1)
Approach\nUse a helper function to convert the string time (HH:MM) into a int of minutes. Simply find the playtime (logout - login) and divide by 15. EZ DUBZ.\n
# Approach\nUse a helper function to convert the string time (HH:MM) into a int of minutes. Simply find the playtime (logout - login) and divide by 15. EZ DUBZ.\n\n# Complexity\n- Time complexity:\n$$O(1)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```c []\n// Convert HH:MM -> time in minutes\nint time_to_int(char *time) {\n    int numtime = 0;\n\n    numtime += (time[0] - 48) * 10 * 60;\n    numtime += (time[1] - 48) * 60;\n    numtime += (time[3] - 48) * 10;\n    numtime += (time[4] - 48);\n\n    return numtime;\n}\n\nint numberOfRounds(char* loginTime, char* logoutTime) {\n    int loginNum = time_to_int(loginTime),\n        logoutNum = time_to_int(logoutTime),\n        playTime = logoutNum - loginNum;\n\n    // Check edge case of not playing at all\n    if (playTime > 0 && playTime < 15) return 0;\n\n    // move login to nearest playable game\n    if (loginNum % 15 != 0) loginNum += (15 - loginNum % 15);\n\n    // Calculate total time at play (handle logout before login)\n    if (logoutNum < loginNum) {\n        playTime = time_to_int("24:00") - loginNum + logoutNum;\n    } else playTime = logoutNum - loginNum;\n\n    return playTime / 15;\n}\n```\n\n\n![](https://assets.leetcode.com/users/images/dc24d73b-2d06-429e-96cb-b71b8df4969e_1699707478.4091067.jpeg)
['C']