Understood or not ? Drop a Yes or No :D .. . Check me out at Instagram: instagram.com/striver_79/ . . If you appreciate the channel's work, you can join the family: bit.ly/joinFamily
@abhiprajapati28354 жыл бұрын
Make videos faster
@sahilchoudhary14734 жыл бұрын
understood
@mutyamreddybejjanki83074 жыл бұрын
Great job bro 🙌
@umapandey67964 жыл бұрын
yes
@mohammedwaseem85992 жыл бұрын
Yes.
@rishitiwari62004 жыл бұрын
Bro don't end this series and please ignore dislikers and don't get demotivated as I came to know about many technique to solve same problem which I submitted in brute force approach
@abhishekkmandal4 жыл бұрын
sound quality has exponentially improved :)
@iampatelajeet4 жыл бұрын
Raj bhai your placement series is really really useful for all students thanks for your efforts .
@sudeshpawar7334 жыл бұрын
I knew this approach but it's always better to understand it from the legend. thanks for making our life easy bro ❤️
@takeUforward4 жыл бұрын
long wla pta tha ?
@sudeshpawar7334 жыл бұрын
@takeuforward Nahi Bro.. as you said this video has something for everyone.
@harshitsaxena7205 Жыл бұрын
@@takeUforward that's why striver is "THE STRIVER"
@himanshumishra87403 жыл бұрын
The overflow problem can be solved without using long and just writing n=abs(n). I did this and it worked fine for me.
@rohandeshmukh39892 жыл бұрын
but i tried to do the way striver did that multiplying it by -1 but it was giving me the error that it cannot store that much value in int and then instead of using that i used abs and it worked but i didn't get why does it works it is same as the first approach i used but still i got wa on first approach
@visheshkaran70832 жыл бұрын
@@rohandeshmukh3989 bro typecast the right hand side with (long) it won't give you error
@satyamsrivastava.4 жыл бұрын
Nice... It is called as Fast Exponential Algorithm I had studied it during B.Tech
@Rajesh-op8zx2 жыл бұрын
you're from which college coz even our IITs dont tech DS ,Algo to us
@aakarsrivastava71932 жыл бұрын
Yeah man, I'm in IIT doing final year of B.Tech+M.Tech in Computer Science and still I've to come to this video to teach myself.
@satyamsrivastava.2 жыл бұрын
So I was preparing for Gate during B.tech at that time, I studied this in Algorithms subject by myself. Same my college didn't teach me this.
@vibhor30493 жыл бұрын
Using recursion- JAVA static double pow(double x, long n){ if(n == 0) return 1; if(n%2 == 0) return pow(x*x, n/2); else return x*pow(x, n-1); } When the function returns the result, do check if n was +ve or -ve and show output accordingly.
@bisatisrilatha79573 жыл бұрын
why use double here and why long for n?????????
@democratcobra3 жыл бұрын
Negative Handel hota hein keya/?
@rajrangwani56694 жыл бұрын
Very nice video...already knew the logn solution but the overflow condition was new which could've easily ruined the interview.......please continue on this series it helps a lot
@nilesh694202 жыл бұрын
Congrats Sir. Big fan.
@2018-y8t4 жыл бұрын
Keep going! This is really helpful!
@aaryannigam9552 Жыл бұрын
I think there is some fault in c++ solution, the if condition is wrong
@studyacc12342 ай бұрын
you didn't explain the recursive one..
@AnkitRaj-ux7lvАй бұрын
//correct code best excpected by any company class Solution { public: double myPow(double x, long long n) { double ankit= pow(x,n)1.0; if(n
@paritoshlambat6562 жыл бұрын
Do u have any idea bitwise operator use that
@divaynagar19294 жыл бұрын
Can I also do the bitwise operators approach , that also works in O(logn) as the number of bits in a number is O(logn) , Please Tell can I do it for that also ??
@ravishankar92472 жыл бұрын
Why have you kept this question in the ARRAYS section of the SDE sheet ??
@kaustavpaul93062 жыл бұрын
Brute Force class Solution { public double myPow(double x, int n) { double ans = x; if(n > 0){ for(int i=1; in; i--) ans = ans / x; } return ans; } }
@syagni_2 жыл бұрын
dont know why, but even after copy-pasting your code i am getting "time limit exceeded" in submission :/
@kaustavpaul93062 жыл бұрын
@@syagni_ yaa thats y its Brute force
@amitagrawal46604 жыл бұрын
All cases got passed except the one below: x = 2.00000 n = -2147483648 Output = 1.00000 Expected = 0.00000
@deepakchoudhary65934 жыл бұрын
use long num= n; because Integer.MAX_VALUE is 2147483647 and Integer.MIN_VALUE is -2147483648 and when you convert to positive it overflows for Int. Hope you understood.
@AnkitSingh-ut7et3 жыл бұрын
@@deepakchoudhary6593 but the idea is not to use trick and compute answer but to find some generic solution to handle such edge case.
@yatinarora12523 жыл бұрын
Hey u can use it in a edge case if n>INT_MIN return 0.0000
@mutyamreddybejjanki83074 жыл бұрын
Don't dislike , he is doing a great job ❤ thank you bhai 😎🙌
@AnkitKumar-ix3fl4 жыл бұрын
This is what we do in binary exponentiation. Bro your videos is very helpful. Keep making this type of content and if u can please make series on dp.
@gamingwithhemend98902 жыл бұрын
Where is this series in your channel. Please share the playlist link (placement series) here
@deep904022 жыл бұрын
Why we r making power +ve when it is negative??
@priyankavasam8769 Жыл бұрын
this logic is just mind blowing.. I wasn't able to think in that angle
@vishwa582911 күн бұрын
better explain using recursion tree.easy to understand
@AdityaSharma-er3gs2 ай бұрын
Can't we just use in build pow() ?
@aryamanjaiswal51633 жыл бұрын
Hello bhaiya, can i know y r u doing this=> ans = (double)(1.0)/(double)(ans), ans and 1.0 are already double then y type casting required?
@shivampurbia61693 жыл бұрын
Why this method and recursion is taking 20ms but inbuilt pow() or ** operator is taking 12 ms why the later one is fast ?
@arnabbiswas5472 Жыл бұрын
I think the solution will not work for n=INT_MIN.
@alokmishra87863 жыл бұрын
thank you for the best explanation and this is very helpful
@MsKoniki4 жыл бұрын
please keep posting bro . really need your help to get placed. still i am begginer into competeive coding
@aysams2 Жыл бұрын
Hey, did you get placed? What company do you work in now?
@MsKoniki Жыл бұрын
@@aysams2 Thankfully yes , i got placed in serviced based MNC and switched to a fintech after that .
@adarshrai95164 жыл бұрын
Thanks for everything ❤️❤️❤️❤️
@kanishkanim4 жыл бұрын
Appreciable....your videos are helping a lot....carry on!!! 🤩🤩
@ranasauravsingh2 жыл бұрын
UNDERSTOOD... !!! Thanks striver for the video... :)
@rohitrai21333 жыл бұрын
why there are so many dislikes in leetcode for this problem!!
@alexmercerind2 жыл бұрын
Thanks! I was using a recursive approach before. I wonder how to handle mod now. EDIT: Nevermind. Thanks for great content.
@govindsharma76963 жыл бұрын
Bhaiya aapse ek request h aap apni 1st year se 4th year / placement tak ki journey share kijiye .. Aap bhi batana ki aapne kya kya problem face ki starting m aapne kese kese overcome kiya ... Kya kya resources use kiye .. and so on .. I know ki sabki journey alag h and har koi ek hi jesi journey nhi follow krta but hume thoda idea lagega ki hume kitni mehnat ki jarurat h tier 3 se achi company tak jane k liye ... Pls do this na bhaiya it's a humble request to u
@anveshasharma27262 жыл бұрын
Shall we do this with recursion in interview?
@lelouchlemprouge63807 ай бұрын
Math.exp(n*Math.log(x)); Ye karne se ajaega aur x positive negative ka sign bit save krdena i think this is fastest?
@AkashSingh-mk7od4 жыл бұрын
Very nicely explained.... it's clearly understood....thankyou bhaiya....your series can definitely help someone feel confident and work more hard.
@roshni93202 жыл бұрын
This solution is still giving me TLE for the long long test case!
@ShreyaSingh-vr9qi4 жыл бұрын
Nice explaination !! bs bhaai videos rokna nahi puri 180 days complete karna.. Thanks so much for helping..
@blitzkrieg54543 жыл бұрын
Hats off to all your hardwork, keep going!
@abhinavmishra76174 жыл бұрын
Although the complexity of both approaches is identical, this approach will be faster in practice since we have the overhead of the recursive calls.
@DR-mq1le Жыл бұрын
in the else condition should it not be "ans=x*x" ?
@amansinghal4663 Жыл бұрын
My recursive solution ( accepted in leetcode ) class Solution { public: double func(double x, int n){ if(n==0){ return 1; } if(n%2 == 0){ return func(x*x, n/2); } else{ return x*func(x*x, n/2); } } double myPow(double x, int n) { if(n
@neelesh6218 ай бұрын
the fun faCT is, there is no difference between c++ & java solution
@davegupta3292 ай бұрын
double myPow(double x, int n) { double pow; pow = exp(n * log(fabs(x))); if (x < 0 && n % 2 != 0) pow = -1 * pow; return pow; } Can it be considered?
@mohammedwaseem85992 жыл бұрын
This code is giving Wrong Answer.
@takeUforward2 жыл бұрын
The code works fine..
@deepakavva3174 жыл бұрын
I think a series on dynamic programming can increase your subscribers.
@ramsai61414 жыл бұрын
yes brother...so many people are waiting for your DP series
@devangpapinwar2083 жыл бұрын
Thank you Trevor
@Morimove Жыл бұрын
this video is linked to recursion on DSA A2Z series but the shown solution is iterative
@takeUforward Жыл бұрын
Yes because this can also be solved using recursion. I will soon add
@Morimove Жыл бұрын
@@takeUforward thankyou sir
@amd74074 жыл бұрын
bro awesome videos ,your sheet helps me a lot , little sound can be improved . But please keep making videos .
@raholsaha81914 жыл бұрын
Nice work bro. You are doing a great job.
@pleasesirmorevideos46844 жыл бұрын
Why dislikes???
@DR-mq1le Жыл бұрын
in the article the c++ code is wrong ,
@chandlerbing8164 Жыл бұрын
not accepted by leetcode submission please explain floating point power as well brother
@himanshidixit64062 жыл бұрын
Completely understood..Thank you so much..:)
@samqureshi94154 жыл бұрын
First time dekha video isse phoe ds or algo kya hai pata he nahi tha . Per dekh kar acha laga ❤️
@mdmuquimakhter51452 жыл бұрын
class Solution { public: double myPow(double x, int n) { long long num=n; double ans=1.0; if(num
@wisdomkhan2 жыл бұрын
how is this interview specific?
@omanshsharma67962 ай бұрын
The quality of explanations seems to be inversely related to the quality of mic :D
@swetantkumar70294 жыл бұрын
Following ur series and waiting next video to come eagerly....Great job man.
@sanskarghyar9408 Жыл бұрын
class Solution { public: double myPow(double x, int n) { if(n
@Techna-to5qt Жыл бұрын
what if n is a real number?
@SHIVAMGUPTA-wb5mw4 жыл бұрын
Following ur series ...plz continue
@kaichang818610 күн бұрын
understood, thanks for the awesome video
@WasimAkram-hb5lr4 жыл бұрын
Brother your is really helpful keep going and ignore hate comments
@akashnarvaria36632 жыл бұрын
Why we have to take long nn? With int nn it is not working Can someone explain?
@shreyash82732 жыл бұрын
Int will overflow for the -intMin value when will make it positive
@deepapandey8492 жыл бұрын
Amazing series + solutions, hats off! Just, this video has very annoying sound quality :(
@chakshusalgotra4 жыл бұрын
thanks all to u sir u been a great help
@parikshitrathore15104 жыл бұрын
In some places the voice of previous and succeding transitions are overlapping!!
@parikshitrathore15104 жыл бұрын
But, understood!!
@takeUforward4 жыл бұрын
@@parikshitrathore1510 Yeah am using a new editor hence this is happening, will check this bro in the next one !
@dhruvrajput51944 жыл бұрын
Really great explanation.. But i think there is some problem with your mic.. Or maybe something's wrong with my earphones😕
@takeUforward4 жыл бұрын
Some problem on my side!
@ketanahuja89394 жыл бұрын
bhiaya not got this line x = x* x; and we are doing nn/=2;
@linhinNTU Жыл бұрын
can anyone explain for me why n needs to be " long long" type?
@jiviteshvarshney3644 Жыл бұрын
For saving large int
@sheikhaman62184 жыл бұрын
Always a helping hand... 😇
@Rahul-tk8ck4 жыл бұрын
U r helping me alot bro.stay safe✨
@sumitkulyal41024 жыл бұрын
Good work bhaiyya. Haters are doing great job, bhaiyya it's means your are doing great job more haters means you are doing right work. Keep going bhaiyya.
@samarthajadhao11764 жыл бұрын
can make videos on C++ tricks...
@sarthak13173 жыл бұрын
The voiceover at 2:22 xD
@letsexplore75903 жыл бұрын
yes
@yashkhatwani31982 жыл бұрын
Thank you
@lakshkaushik63664 жыл бұрын
Can u help me by guiding me how to start doing this stuff I am in 12 th now
@39_jatinjain4 Жыл бұрын
can anyone plz tell me where i am doing wrong?? class Solution { public: double sol(double x,long n){ // base case if(n==0) return 1; return x*sol(x,n-1); } double myPow(double x, int n) { long z=abs(n); if(n%2!=0) z=z+1; double t= sol(x,z/2); double ans=t*t; if(n%2!=0) ans=ans/x; if(n
@RaaheeAmit4 жыл бұрын
U help us alot
@divyanshigupta15682 жыл бұрын
You are truly a legend 👏🏻
@nopecharon2 жыл бұрын
Thanks
@AshishKumar-me8pr4 жыл бұрын
Stiver_79 you are Genius.. excellent
@redhathacker34583 жыл бұрын
Yes
@atulmalakar4 жыл бұрын
Naming of variables could have been better.
@BRSanush3 жыл бұрын
Happy teachers day Striver sir🎉
@het3142 жыл бұрын
using long is kinda cheating. Try diving when n
@israkulhaquetusher32564 жыл бұрын
SDE sheet. link isn't working
@tannukumari51444 жыл бұрын
great work bhaiya, thank you
@abhinavmishra76174 жыл бұрын
why didn't we do binary exponentiation? fast_power.... pow(a,n){ base cases b=pow(a,n/2); if(n%2==1) return b*b*a; return b*b; }
@takeUforward4 жыл бұрын
Watch the video, you wrote the recursive solution for the same. Dont learn the codes, understand the algo, then you will know that both are same!
@abhinavmishra76174 жыл бұрын
@@takeUforward bhai maine yaad to nahi kiya h....ye kaise bol diye aap? n if mai apne doubt clear krne k liye comment krunga to tum aise reply karoge? not cool
@takeUforward4 жыл бұрын
Nai bro, aapne pucha binary exponentiation kyu use nai kia aapne. Yahi comment tha? Th mne suggestion dia. Kyu ki agar algos smjhoge th ye puchte nai. Baaki tum isse constructive loge toh next time sayad tm analysis kroge :) rest me chahta th comment ka ni v reply kr skta tha.. but me kia so that tm smjho ye chiz ki tm algos smjhe ni. Logic tmhre code ki smjhte th ye question aati hi nai as dono same. Bs video wali iterative h tumhri code recursive!!
@abhinavmishra76174 жыл бұрын
@@takeUforward ok bhai... actually mere liye recursive zyada intuitive h maybe isliye main iteratively nhi smjh paya isliye bs maine puchha
@takeUforward4 жыл бұрын
Abhinav Mishra intuitive ho sakta hai but agar tumhe pta h n odd p n-1 kr rhe and n even pe n/2, toh ye recursion me kyu kr rhe ho? Wahi reason mene bataya h. Th dono same hua na ?? Interviews m agar tum ase dono ko alag bologe th dikkat ho skti, iskie ache se analyse kro, like try to write both iterative and recursive
@Learnprogramming-q7f7 ай бұрын
Thank you Bhaiya
@enigma28863 жыл бұрын
thanks !
@MaheshPatil-of1zy7 ай бұрын
its 2024 feb i am watching 😊
@aditya_sipani5 ай бұрын
what is nn here,like ?
@Ankitkumar-gc5cc3 ай бұрын
That is just storing value of n so that while we change the value of nn in loop we can retain value of n and that can be used for final return statement where he is checking if it's negative or positive
@tejasjoshi19073 жыл бұрын
Why this question has so many dislikes on leetcode.??