Ceiling & Floor - Java
Intuition\n Describe your first thoughts on how to solve this problem. \nConvert to minutes first, calculate ceiling of login time and floor of logout time by 1
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nConvert to minutes first, calculate ceiling of login time and floor of logout time by 15 minutes. Tedious corner cases, need to keep the original time for handling logic.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int numberOfRounds(String loginTime, String logoutTime) {\n        int loginOrig = Integer.parseInt(loginTime.substring(0, 2)) * 60 + Integer.parseInt(loginTime.substring(3, 5));\n        int logoutOrig = Integer.parseInt(logoutTime.substring(0, 2)) * 60\n                + Integer.parseInt(logoutTime.substring(3, 5));\n        int login = loginOrig == 0 ? 0 : (loginOrig - 1) / 15 + 1;\n        int logout = logoutOrig / 15;\n        //System.out.println(loginOrig + "|" + logoutOrig + "\\n" + login + "|" + logout);\n        return logoutOrig >= loginOrig ? Math.max(0, logout - login) : logout + 24 * 4 - login;\n    }\n}\n```
['Java']