L4. Print all prime factors of a Number | Maths Playlist

  Рет қаралды 54,630

take U forward

take U forward

Күн бұрын

Пікірлер: 72
@md.ualiurrahmanrahat2400
@md.ualiurrahmanrahat2400 5 ай бұрын
The optimal approach is so amazing. Thanks Striver for GOAT level stuff.
@rahulmandal4007
@rahulmandal4007 4 ай бұрын
Its ok bro check out TUF+
@tedbundy8712
@tedbundy8712 4 ай бұрын
You are the GOAT In DSA on youtube
@rahulmandal4007
@rahulmandal4007 4 ай бұрын
That I am ☺
@2amCoder
@2amCoder 8 ай бұрын
last solution was actually something i never came across has thought of it but never applied great vid
@rahulmandal4007
@rahulmandal4007 4 ай бұрын
Its ok bro check out TUF+
@Madhu-e7n
@Madhu-e7n 2 күн бұрын
understood......best teaching ever
@HarshvardhanSankpal
@HarshvardhanSankpal 6 ай бұрын
12:30 in this code we need to also apply isPrime( i ) in the if statement, else we are blindly adding also the divisors, but the question demands prime divisors.
@afreenmohammad8716
@afreenmohammad8716 6 ай бұрын
no you are wrong. for example,2 is a prime number. when 2 divdes the number as many times as possible then 2 mutiples cannot divide the number. similarly for 3 etc.
@yashwanthyerra2820
@yashwanthyerra2820 2 ай бұрын
Yeah if 2 and 3 divides number as no of times as possible 6 cannot be able divide the numbers so only prime numbers are added to list Inherently he is using prime sieve approch here but in different way
@batmanlovesjokerr
@batmanlovesjokerr 8 ай бұрын
8:30- actual method 14:40 more optimised
@hardikpatel352
@hardikpatel352 6 ай бұрын
understood class Solution{ public: vectorAllPrimeFactors(int N) { vector vec; for(int i=2; i
@shahzaneerahmed1507
@shahzaneerahmed1507 2 ай бұрын
You are a legend @striver!
@anshgupta8860
@anshgupta8860 6 ай бұрын
for number like 37 ,n stilll remains 37 which is a factor ,so we add and in case of 16 ,n reduces to 1 ,so we dont need to add it to list ,that;s why n!=1 then add to list
@mohammedraheel2223
@mohammedraheel2223 9 ай бұрын
One after other video is uploading it is very much satisfying for the beginners😊.. Thanks a lot Striver Bhaiya ❤
@rahulmandal4007
@rahulmandal4007 4 ай бұрын
Its ok bro check out TUF+
@stith_pragya
@stith_pragya 8 ай бұрын
Understood......Thank You So Much for this wonderful video......🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@rahulmandal4007
@rahulmandal4007 4 ай бұрын
Its ok bro check out TUF+
@Anonymous____________A721
@Anonymous____________A721 9 ай бұрын
God of dsa and cp
@Express871
@Express871 9 ай бұрын
Can you videos on your own dsa sheet string Question
@kedarmalap7525
@kedarmalap7525 9 ай бұрын
Can you please upload detailed video on strings....
@knowthrvdo
@knowthrvdo 9 ай бұрын
Plz complete remaining sheet as well
@SibiRanganathL
@SibiRanganathL 4 ай бұрын
Amazing done and dusted
@veerverma5586
@veerverma5586 9 ай бұрын
Bhaiya string and recursion ka kya plan hai??
@es_amit
@es_amit 9 ай бұрын
aditya verma se pdhle recursion bhot mst hai uska
@veerverma5586
@veerverma5586 9 ай бұрын
@@es_amit phir lekin sequence toot jayega, ab dekhta hoon agar thode din tak nhi kiya post toh kahi or se he krna padega
@es_amit
@es_amit 9 ай бұрын
@@veerverma5586 bhai ek baar pdh ke toh dekh fir btaio (recursion) Aditya verma se. mera recursion bhot weak tha phle ab dp ke questions bde aaram se solve kr deta hu
@veerverma5586
@veerverma5586 9 ай бұрын
@@es_amit ohh 😮, yeh he hai kya 19 videos wala?
@es_amit
@es_amit 9 ай бұрын
@@veerverma5586 ha Bhai aaram se dekh fir btaio mujhe kaisi lgi, backtracking ki bhi dekh lio
@subee128
@subee128 8 ай бұрын
Thank you very much
@sonix_plays
@sonix_plays 3 ай бұрын
Can anyone tell me in the most optimal solution why we go only to the root n times? Like what is the intuition behind it? 😢
@kumarshreyas7899
@kumarshreyas7899 2 ай бұрын
you want to find the prime factors so for example 1600 sq.root(1600) == 40 now 41 is just greater than 40 and also a prime number but 41^2 >1600 and also 39 just lesser than 40 , 39^2
@x-dev-johndoe
@x-dev-johndoe 3 ай бұрын
#include using namespace std; #define ll long long #define vint vector #define eb emplace_back vint primeFactors(int n){ vint factors; if(n%2==0){ factors.eb(2); n/=(n & -n); } for(ll i=3; i*i2) factors.eb(n); return factors; } int main() { int n; cin >> n; vint v=primeFactors(n); for(int itm: v){ cout
@prajjwaltripathi2374
@prajjwaltripathi2374 8 ай бұрын
I can't find the c++ code for the last method, please someone help!
@udayshankar-e6v
@udayshankar-e6v 9 ай бұрын
Time hi nahi mil reha h abhi...varana ek din me ye playlist khatam kar denge... Striver Jindabaad! 😂
@nayankhuman1043
@nayankhuman1043 2 ай бұрын
Thanks a lot :)
@reddygopichand2002
@reddygopichand2002 9 ай бұрын
Understood ❤
@VikashPatel-sf6ub
@VikashPatel-sf6ub 9 ай бұрын
In last approach, why we are adding n in list if it's not equal to 1 without checking it's prime or not.
@mrinmoykalita4456
@mrinmoykalita4456 8 ай бұрын
Considering worst case of factors of primes of number can go upto number. So, we are considering total spaces upto the numbers.
@yash2275
@yash2275 8 ай бұрын
See If there is the value Of N which is prime then we are iterating i upto sqrt N so we will not reach to the N through i but we know that if n is not 1 then it will also be the factor so we will add it to the answer see dry run the code for 65 then you will understand
@shivamdhiman3488
@shivamdhiman3488 3 ай бұрын
where can i get code of this video ....plz provide link if any....??
@codeman3828
@codeman3828 8 ай бұрын
Understood. thanks
@shashankgsharma0901
@shashankgsharma0901 5 ай бұрын
Understood!
@SitaRam-m1i
@SitaRam-m1i Ай бұрын
Understood
@chiragbansod8252
@chiragbansod8252 9 ай бұрын
understood
@HarshvardhanSankpal
@HarshvardhanSankpal 6 ай бұрын
for solving the edge case of 37, cant we simpliy check if n is prime, if yes, we know theres only 1 pime factor that is itself ??
@anonymous10906
@anonymous10906 5 ай бұрын
consider for 35
@AkOp-bf9vm
@AkOp-bf9vm 7 ай бұрын
did anyone understand the last 16 example which he give to try itself
@vipuljamod4119
@vipuljamod4119 6 ай бұрын
n = 16. (1) i = 2 i*i = 4 < 16 16 % 2 = 0 . list.add(2) while(n % 2 == 0) { 16/2 = 8 8/2 = 4 4/2 = 2 2/2 = 1. } Now while loop break. i is become 3 and n is become 1. 3 * 3 = 9 < 1 ❌ so condition false So for loop break. And now check if n != 1 n = 1 and 1 = 1 so condition false ❌ And final ans list = [2]
@AkOp-bf9vm
@AkOp-bf9vm 5 ай бұрын
@@vipuljamod4119 thnx bro
@wul_frik
@wul_frik 7 ай бұрын
I have a doubt, why can't multiple prime numbers be there after the loop ends, like after the for loop ends, the number might be something like p1 * p2, where p1 and p2 are primes?
@vipuljamod4119
@vipuljamod4119 6 ай бұрын
If n = 221. Then i * i
@AkbarKhan-gd2bw
@AkbarKhan-gd2bw 8 ай бұрын
💖💖💖
@codingp110
@codingp110 5 ай бұрын
US!
@praphullpandey425
@praphullpandey425 9 ай бұрын
First view ❤
@gauristar4094
@gauristar4094 7 ай бұрын
But the final optimized approach doesn't work for some numbers like 6.
@vipuljamod4119
@vipuljamod4119 6 ай бұрын
public static ArrayList primeFactor(int n) { ArrayList al = new ArrayList(); for(int i=2; i * i
@vipuljamod4119
@vipuljamod4119 6 ай бұрын
Try this code.., this working perfectly.
@AkashSingh-vloger
@AkashSingh-vloger 5 ай бұрын
Yes bro ​@@vipuljamod4119
@AdityaGrover-ly9jf
@AdityaGrover-ly9jf 9 ай бұрын
First view
@genzsubh
@genzsubh 9 ай бұрын
Nhi karna print bhai... Kyu paresan kr rha h. Job dega to bol
@priyanshubiswas9396
@priyanshubiswas9396 7 ай бұрын
tujhe toh waise v koi job na de🤣🤡
@genzsubh
@genzsubh 7 ай бұрын
@@priyanshubiswas9396 🤣🤣🤣🤣
@abhirajranjan1518
@abhirajranjan1518 3 ай бұрын
Bit Manipulation is better taught by Luv
@anshgupta8860
@anshgupta8860 6 ай бұрын
understood
@hardikpatel352
@hardikpatel352 6 ай бұрын
understood
@shaiksoofi3741
@shaiksoofi3741 6 ай бұрын
understood
L5. Power Exponentiation | Maths Playlist
12:39
take U forward
Рет қаралды 36 М.
L3. Check if a Number if Prime or not | Maths Playlist
7:10
take U forward
Рет қаралды 45 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Square Root of Imaginary Number
8:31
Andy Math
Рет қаралды 76 М.
How Git Changed Programming Forever
9:13
JetBrains Academy
Рет қаралды 3,1 М.
IIT-JEE Toppers: Where Are They Now?
15:52
Mohak Mangal
Рет қаралды 2,8 МЛН
You have 30 seconds. Viral riddle from The 1% Club
8:42
MindYourDecisions
Рет қаралды 46 М.
L6. Sieve of Eratosthenes | Maths Playlist
18:27
take U forward
Рет қаралды 66 М.
Crazy IIT JEE advice from AIR 1🔥
7:21
Quantum Project - Tharun Speaks
Рет қаралды 183 М.
ML Was Hard Until I Learned These 5 Secrets!
13:11
Boris Meinardus
Рет қаралды 346 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН