• + 10 comments

    Hello friends,

    In this video tutorial, I have explained hackerrank drawing book solution algorithm. hackerrank drawing book problem can be solved by using mathematics. The complexity of drawing book hackerrank solution is O (1)

    If interested to know more about the generic algorithm in details-

    click here for the video explanation of generic algorithm with complexity analysis.

    or you can click on the image too to follow youtube tutorial.

    Here is the working solution:-

    source code :

    static int pageCount(int n, int p) {
    
    		int totalPageTurnCountFromFront = n / 2;
    		int targetPageTurnCountFromFront = p / 2;
    		int targetPageTurnCountFromBack = totalPageTurnCountFromFront - targetPageTurnCountFromFront;
    
    		return Math.min(targetPageTurnCountFromFront, targetPageTurnCountFromBack);
    
    	}
    

    Would really appreciate your feedback like, dislike , comment etc. on my video.

    Do not forget to upvote, if you find it useful.