Hello Coding Lover, If you have any doubts or any better approach to solve this problem, let me know in comments.
@tazzyreign26294 жыл бұрын
Love the solution!
@noibiolamilekan35012 жыл бұрын
The best solution so far! You are too good
@kishlayamourya31414 жыл бұрын
You made the question looks so easy...nice explanation.
@JavaAidTutorials4 жыл бұрын
thank you. 🙂
@SaumyaSharma0074 жыл бұрын
thanks a lot, SIR..............that was very helpful.
@JavaAidTutorials4 жыл бұрын
Most welcome!
@shubhamtiwari52973 жыл бұрын
Simple, Understandable Logic Great work New Subscriber Cheers
@jordenparker64545 жыл бұрын
Thank you so much for this, man! Your explanation really helped me out. :)
@JavaAidTutorials5 жыл бұрын
Thanks, Jorden for your feedback. keep watching and keep commenting..:) It motivates me to do more for you all..
@prijaymaharjan4 жыл бұрын
Thank you clear all doubt in Draw Book Solution Algorthm
@JavaAidTutorials4 жыл бұрын
You are most welcome
@mkriiger3 жыл бұрын
Simple and elegant solution, nice!
@JavaAidTutorials3 жыл бұрын
Thank you! Cheers!
@atiqshaikh60103 жыл бұрын
what if count starts from 1 which will be on the left side of the page 1,2 --- 3,4 ----- 5,6 (like this) i think n/2 wont work in this case
@GauravKumar-ux1os4 жыл бұрын
Brilliant sir!
@smartcoder11125 жыл бұрын
perfect tutorials for the beginner (Y). You Rocked bro...!!!
@JavaAidTutorials5 жыл бұрын
Thanks buddy..
@vinayabhat48263 жыл бұрын
thank you !! It helped me a lot!!
@pramodbasu77324 жыл бұрын
Great Explanation !!
@pramodbasu77324 жыл бұрын
grate Explanation !!!
@shubhamsagar91534 жыл бұрын
thanks mate your videos are helping me a lot since I am net to competetive coding. but can i ask you what to do when you r stuck on a question for days and logic does not click its very frustrating.
@JavaAidTutorials4 жыл бұрын
i hope my quora answer will cover this- www.quora.com/Is-not-being-able-to-solve-HackerRank-problems-for-a-beginner-normal/answer/Kanahaiya-Gupta-2
@amanrai80105 жыл бұрын
I have watched your video it was really easy to understand and was really efficient. Thanks for sharing
@JavaAidTutorials5 жыл бұрын
Thanks Aman for your compliment..
@RobertShane4 жыл бұрын
I thought there was a way of doing it where you could only calculate from the front and then subtract off something to get from the back but I couldn't figure it out. Thanks.
@gokulnaathb26273 жыл бұрын
Thank you for the explanation, Sir :)
@codear25193 жыл бұрын
good video thank you
@soham_narang44874 жыл бұрын
what if n=12 it gives a different output for p=8 and p=9, but instead, it should be the same
@mrinmoyhalder72934 жыл бұрын
I think we have to take floor value always
@JavaAidTutorials4 жыл бұрын
In java 8/2 and 9/2 both are equal to 4. So answer will be same for both. If you are using some other language check if division works in the same way or else take floor value as mentioned in above comment.
@ManojKumar-hu6uk5 жыл бұрын
very good explanation.
@JavaAidTutorials5 жыл бұрын
Thanks, Manoj for your compliment..!!
@mdabidiqbal11535 жыл бұрын
Thank you so much
@JavaAidTutorials5 жыл бұрын
Most welcome..
@anilappana88334 жыл бұрын
Good logic
@JavaAidTutorials4 жыл бұрын
thank you..!1
@djamelnm77404 жыл бұрын
Thank you very much
@JavaAidTutorials4 жыл бұрын
Welcome 😊
@soumyat48613 жыл бұрын
N/2 is understood as each flip has 2 pages but why we assigned target pagecount from front as p/2? Can you please explain
@lostt34352 жыл бұрын
even from the front if u wanna go to target page it will require p/2 turns, as p here is target page.Simply like we do in maths we have just put the value of p in n/2
@khii_khii9 ай бұрын
best one
@rohanshrivastav13825 жыл бұрын
thank you bro
@JavaAidTutorials5 жыл бұрын
welcome bro.. thanks for watching..!!
@biswadeepchakraborty53545 жыл бұрын
Thank you so much. I want to learn Dynamic programming. Could you please help
@JavaAidTutorials5 жыл бұрын
welcome @Biswadeep. Sure will make a tutorial on dynamic programming soon. stay tuned.
@arjunseth58363 жыл бұрын
@@JavaAidTutorials Is tutorials on DP there? I couldn't find any..
@i_am_kshitij11184 жыл бұрын
if n=10 and p=7 then from right to left we require 2 turns but from the formula we are getting (10-7)/2=3/2=1 what is wrong here should i put another condition that if n==even and p==odd then turns from end is equal to (n-p)/2 +1
@JavaAidTutorials4 жыл бұрын
int totalPageTurnCountFromFront = 10 / 2 =5; int targetPageTurnCountFromFront = 7 / 2 =3; int targetPageTurnCountFromBack = totalPageTurnCountFromFront - targetPageTurnCountFromFront; targetPageTurnCountFromBack=5-3=2 return Math.min(3, 2); answer 2 hope , it will hellp.
@mruduladdipalli54175 жыл бұрын
Great!
@JavaAidTutorials5 жыл бұрын
Thanks Mrudul..
@anuragtiwari30325 жыл бұрын
Great explanation bro but can u please help explain the editorial answer of this problem as their is some left right shifting involved which im unable to understand.i know how the shifts work but I'm unable to understand the logic behind it
@JavaAidTutorials5 жыл бұрын
Thanks @Anurag. Lets take this sample input- n=7 p=4 graphical view of book will look something like this- [ ,1][2,3][4,5][6,7] every interval bracket[x,y] represent the book with x page on left and y page on right. They are calculating no. of turns from right to left (from last) If n is odd, then she turns(n-p)/2 pages. because if n is odd it means total page either be 1 or 3 or 5 ...any odd number and page 1 is always fix. so if you subtract one from odd number it will become even and every page contains 2 pages. so we can divide it by 2 now. so it will be p/2. if you go from left to right or (n-p)/2 if you will go right to left(they used right to left strategy). If n is even, then she turns (n-p+1)/2 pages.because if n is even and 1 page place is fixed then we are left with an odd number. ex- [ ,1][2,3][4,5][6,7][8, ] in this example after leaving 1 page we left with 7 page and if divide 7/2 it will integer division so it will result 3(instead of 3.5 because there are one more page left) turns which include only 6 pages as per page 2 page number.so while considering from right to left you need to add 1 into the above formula. (n-p+1)/2 I hope. you got the idea.
@anuragtiwari30325 жыл бұрын
@@JavaAidTutorials thanx a lot man for this explanation. yeah I got the idea. May god bless u :)
@JavaAidTutorials5 жыл бұрын
@@anuragtiwari3032 most welcome..:)
@mrinmoyhalder72934 жыл бұрын
How did u clicked this logic by seeing this problem 1st time ??
@JavaAidTutorials4 жыл бұрын
Frankly speaking, This was not the first problem for me, I have solved this kind of problems, thats why i knew this.😊 I hope now you know this trick and will be able to apply on your similar future problems.
@anujgupta77494 жыл бұрын
@@JavaAidTutorials Thank you sir.
@IamDemotivated4 жыл бұрын
🙏🙏🙏🙏🙏🙏
@devanshsrivastava42655 жыл бұрын
import java.util.Scanner; class Solution{ public static void main(String[] args) { Scanner Scan = new Scanner(System.in); int total = Scan.nextInt(); int pagee =Scan.nextInt(); if(total%2==0) { total++; } int div=pagee/2; int div_back=(total-pagee)/2; if(pagee==1 || pagee==total) {System.out.print("0");} else if(div>div_back) { System.out.println(div_back); } else if(div
@JavaAidTutorials5 жыл бұрын
thank you.
@r_shinchan24595 жыл бұрын
Today's problem and their solution pe drawing banani he