How To Solve HackerRank Drawing Book Problem

  Рет қаралды 17,334

JAVAAID - Coding Interview Preparation

JAVAAID - Coding Interview Preparation

Күн бұрын

Пікірлер: 71
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Hello Coding Lover, If you have any doubts or any better approach to solve this problem, let me know in comments.
@tazzyreign2629
@tazzyreign2629 4 жыл бұрын
Love the solution!
@noibiolamilekan3501
@noibiolamilekan3501 2 жыл бұрын
The best solution so far! You are too good
@kishlayamourya3141
@kishlayamourya3141 4 жыл бұрын
You made the question looks so easy...nice explanation.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
thank you. 🙂
@SaumyaSharma007
@SaumyaSharma007 4 жыл бұрын
thanks a lot, SIR..............that was very helpful.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Most welcome!
@shubhamtiwari5297
@shubhamtiwari5297 3 жыл бұрын
Simple, Understandable Logic Great work New Subscriber Cheers
@jordenparker6454
@jordenparker6454 5 жыл бұрын
Thank you so much for this, man! Your explanation really helped me out. :)
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Thanks, Jorden for your feedback. keep watching and keep commenting..:) It motivates me to do more for you all..
@prijaymaharjan
@prijaymaharjan 4 жыл бұрын
Thank you clear all doubt in Draw Book Solution Algorthm
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
You are most welcome
@mkriiger
@mkriiger 3 жыл бұрын
Simple and elegant solution, nice!
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
Thank you! Cheers!
@atiqshaikh6010
@atiqshaikh6010 3 жыл бұрын
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-ux1os
@GauravKumar-ux1os 4 жыл бұрын
Brilliant sir!
@smartcoder1112
@smartcoder1112 5 жыл бұрын
perfect tutorials for the beginner (Y). You Rocked bro...!!!
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Thanks buddy..
@vinayabhat4826
@vinayabhat4826 3 жыл бұрын
thank you !! It helped me a lot!!
@pramodbasu7732
@pramodbasu7732 4 жыл бұрын
Great Explanation !!
@pramodbasu7732
@pramodbasu7732 4 жыл бұрын
grate Explanation !!!
@shubhamsagar9153
@shubhamsagar9153 4 жыл бұрын
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.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
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
@amanrai8010
@amanrai8010 5 жыл бұрын
I have watched your video it was really easy to understand and was really efficient. Thanks for sharing
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Thanks Aman for your compliment..
@RobertShane
@RobertShane 4 жыл бұрын
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.
@gokulnaathb2627
@gokulnaathb2627 3 жыл бұрын
Thank you for the explanation, Sir :)
@codear2519
@codear2519 3 жыл бұрын
good video thank you
@soham_narang4487
@soham_narang4487 4 жыл бұрын
what if n=12 it gives a different output for p=8 and p=9, but instead, it should be the same
@mrinmoyhalder7293
@mrinmoyhalder7293 4 жыл бұрын
I think we have to take floor value always
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
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-hu6uk
@ManojKumar-hu6uk 5 жыл бұрын
very good explanation.
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Thanks, Manoj for your compliment..!!
@mdabidiqbal1153
@mdabidiqbal1153 5 жыл бұрын
Thank you so much
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Most welcome..
@anilappana8833
@anilappana8833 4 жыл бұрын
Good logic
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
thank you..!1
@djamelnm7740
@djamelnm7740 4 жыл бұрын
Thank you very much
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Welcome 😊
@soumyat4861
@soumyat4861 3 жыл бұрын
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
@lostt3435
@lostt3435 2 жыл бұрын
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_khii
@khii_khii 9 ай бұрын
best one
@rohanshrivastav1382
@rohanshrivastav1382 5 жыл бұрын
thank you bro
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
welcome bro.. thanks for watching..!!
@biswadeepchakraborty5354
@biswadeepchakraborty5354 5 жыл бұрын
Thank you so much. I want to learn Dynamic programming. Could you please help
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
welcome @Biswadeep. Sure will make a tutorial on dynamic programming soon. stay tuned.
@arjunseth5836
@arjunseth5836 3 жыл бұрын
@@JavaAidTutorials Is tutorials on DP there? I couldn't find any..
@i_am_kshitij1118
@i_am_kshitij1118 4 жыл бұрын
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
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
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.
@mruduladdipalli5417
@mruduladdipalli5417 5 жыл бұрын
Great!
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Thanks Mrudul..
@anuragtiwari3032
@anuragtiwari3032 5 жыл бұрын
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
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
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.
@anuragtiwari3032
@anuragtiwari3032 5 жыл бұрын
@@JavaAidTutorials thanx a lot man for this explanation. yeah I got the idea. May god bless u :)
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
@@anuragtiwari3032 most welcome..:)
@mrinmoyhalder7293
@mrinmoyhalder7293 4 жыл бұрын
How did u clicked this logic by seeing this problem 1st time ??
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
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.
@anujgupta7749
@anujgupta7749 4 жыл бұрын
@@JavaAidTutorials Thank you sir.
@IamDemotivated
@IamDemotivated 4 жыл бұрын
🙏🙏🙏🙏🙏🙏
@devanshsrivastava4265
@devanshsrivastava4265 5 жыл бұрын
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
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
thank you.
@r_shinchan2459
@r_shinchan2459 5 жыл бұрын
Today's problem and their solution pe drawing banani he
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Sorry, I did not get that? 😃
@preetiipriya
@preetiipriya 3 жыл бұрын
why didn't i think this way
@ahmedouyahya
@ahmedouyahya 4 жыл бұрын
Thank you sooooooooo much.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Most welcome 😊
@lasithadulshan7357
@lasithadulshan7357 3 жыл бұрын
Thank you !
@juborajroypavel8342
@juborajroypavel8342 4 жыл бұрын
Thank you so much.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
You're welcome!
How To Solve Angry Professor HackerRank Problem
6:20
JAVAAID - Coding Interview Preparation
Рет қаралды 7 М.
Jumping On The Clouds HackerRank Solution [One Liner Solution]
26:26
JAVAAID - Coding Interview Preparation
Рет қаралды 52 М.
風船をキャッチしろ!🎈 Balloon catch Challenges
00:57
はじめしゃちょー(hajime)
Рет қаралды 62 МЛН
У вас там какие таланты ?😂
00:19
Карина Хафизова
Рет қаралды 24 МЛН
How Strong is Tin Foil? 💪
00:25
Brianna
Рет қаралды 68 МЛН
How To Solve Counting Valleys HackerRank Problem
17:00
JAVAAID - Coding Interview Preparation
Рет қаралды 45 М.
Drawing Book | HackerRank | Algorithms | Interview
9:37
Coding Cart
Рет қаралды 3 М.
How To Solve Number Line Jumps | Kangaroo | HackerRank Problem [ Using Formula ]
13:09
JAVAAID - Coding Interview Preparation
Рет қаралды 33 М.
23 - Drawing Book | Implementation | Hackerrank Solution | Python
3:46
New Year Chaos HackerRank Solution
23:56
JAVAAID - Coding Interview Preparation
Рет қаралды 52 М.
Subarray division
33:17
TAP ACADEMY
Рет қаралды 2,8 М.
Count Triplets Hackerrank Solution | Interview Preparation Kit
29:59
JAVAAID - Coding Interview Preparation
Рет қаралды 37 М.
My Unconventional Coding Story | Self-Taught
27:14
Travis Media
Рет қаралды 657 М.
風船をキャッチしろ!🎈 Balloon catch Challenges
00:57
はじめしゃちょー(hajime)
Рет қаралды 62 МЛН