My easy and intuitive solution
This was what I came up with , its pretty straightforward and I think its an O(1) time and space solution , now hear me out , I have used substring function whi
This was what I came up with , its pretty straightforward and I think its an O(1) time and space solution , now hear me out , I have used substring function which takes linear time , and also used loops for looping from start time to finish time , but I would still call it constant time and space because the length of input string is constant , its just time in hours and minutes , so my substring function becomes constant time , and in my loop , it runs at maximum for 24 hours , which is also constant , so overall O(1) time and space\n\nI have looked at other solutions but I have a hard time understanding how they work and I think this solution is good enough \n\nHere is my code , if you have any doubts then do comment down below and I will help you out , oh and by the way dont forget to dislike this question because it SUCKS\n\n```\nclass Solution {\n    public int numberOfRounds(String startTime, String finishTime) {\n        int si1 = -1; // position of ":" in start\n        int si2 = -1; // position of ":" in finish\n        for(int i =0;i<startTime.length();i++){\n            if(startTime.charAt(i)==\':\'){\n                si1 = i;\n                break;\n            }\n        }\n        for(int i =0;i<finishTime.length();i++){\n            if(finishTime.charAt(i)==\':\'){\n                si2 = i;\n                break;\n            }\n        }\n        // split given time zones into hours and minutes\n        int h1 = Integer.parseInt(startTime.substring(0,si1));\n        int m1 = Integer.parseInt(startTime.substring(si1+1));\n        int h2 = Integer.parseInt(finishTime.substring(0,si2));\n        int m2 = Integer.parseInt(finishTime.substring(si2+1));\n        int count = 0;\n        if(h2<h1||(h2==h1&&m2<m1)) h2+=24; // this is the case when \n        // you play overnight so you add 24 hours\n        for(int i = h1;i<=h2;i++){\n            int startM = (i==h1?m1:0); // if its the first hour\n            // then you start from given minute otherwise \n            // you start from the very start of the hour\n            int endM = (i==h2?m2:59); // if its the last hour\n            // then you end at given minute otherwise\n            // you end at the very end of the hour\n            for(int j = startM;j<=endM;j++){\n                if(j==0||j==15||j==30||j==45){ // timestamps when you start the game\n                    if(j+15<=endM||(j==45&&(i<h2))) count++;\n                    // for j = 0,15,30 , you need to check\n                    // if after finishing the game your \n                    // time is less than end minute \n                    // and for j = 45 you need to check if \n                    // there is still one more hour left \n                    // for you to finish your game \n                }\n            }\n        }\n        return count;\n    }\n}\n```\n
['Java']