The Number of Full Rounds You Have Played Efficient Resolution
Intuition\n Describe your first thoughts on how to solve this problem. \nIn summary, we divided the processing of the input into several functions, filtering th
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIn summary, we divided the processing of the input into several functions, filtering the information we need to calculate the rounds played.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe functions are "schedule", responsible for converting the given strings into login and logout times (which are stored in an array); "fortyEightFormat", which checks if the player played for more than one day, and if so, converts the logout time to a 48-hour format; and finally, "workingHours", which converts the login and logout times to the times of the first and last complete rounds played, respectively.\n\nWith the result from "workingHours", we simply iterate, advancing in 15-minute increments and calculating the rounds played (1 for each 15 minutes that pass).\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(1), although the method numberOfRounds has a loop that could vary with the time range, the size of the problem is limited and does not grow with the input size.\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(4), due to the fixed size of the arr array, which is used to store the login and logout times\n# Code\n```\nclass Solution {\n    public void schedule(String login, String logout, int[] arr) {\n        arr[0] = ( (Character.getNumericValue(login.charAt(0))) * 10) + (Character.getNumericValue(login.charAt(1)));\n        arr[1] = ( (Character.getNumericValue(login.charAt(3))) * 10) + (Character.getNumericValue(login.charAt(4)));\n        arr[2] = ( (Character.getNumericValue(logout.charAt(0))) * 10) + (Character.getNumericValue(logout.charAt(1)));\n        arr[3] = ( (Character.getNumericValue(logout.charAt(3))) * 10) + (Character.getNumericValue(logout.charAt(4))); \n    }\n\n    public void workingHours(int[] arr) {\n        int restLogin = arr[1] % 15;\n        int restLogout = arr[3] % 15;\n        if(restLogin != 0) {\n            int complement = 15 - restLogin;\n            if(arr[1] + complement < 60) {\n                arr[1] = arr[1] + complement;\n            } else {\n                arr[0] += 1;\n                arr[1] = 0;\n            }\n        }\n        if(restLogout != 0) {\n            arr[3] = arr[3] -  restLogout;\n        }\n    }\n\n    public void fortyEightFormat(int[] arr) {\n        if((arr[2] < arr[0]) || (arr[2] == arr[0] && arr[3] < arr[1])) {\n            arr[2] = arr[2] + 24;\n        }        \n    }\n\n    public int numberOfRounds(String loginTime, String logoutTime) {\n        int[] arr = new int[4];\n        schedule(loginTime, logoutTime, arr);\n        fortyEightFormat(arr);\n        workingHours(arr);\n        int hAux = arr[0], mAux = arr[1];\n        int rounds = 0;\n        while((hAux < arr[2]) || (hAux == arr[2] && mAux < arr[3])) {\n            if(mAux < 45) {\n                rounds++;\n                mAux += 15;\n            } else {\n                rounds++;\n                mAux = 0;\n                hAux += 1;\n            }\n        }\n        return rounds;\n    }\n}\n```
['Java']