Thank you for the great explanation for time and space complexity please can you cover all the DS topics to make us understand in great way.. thank you once again
@@codewithsimran9899 Thank you for the wonderful explanation. In this case, when combining O(n) with O(logn), instead of O(nlogn) why cant we say it is O(n). O(n) has a bigger time compared to O(logn)
When you're multiplying complexities they become one entity for example n log n is one entity and n^2 is one entity so we can't separate them out because they're nested and one piece of the program. However when we're adding n + log n that time first one task ran whose time complexity is n and then another task ran whose time complexity is log n so we treat them separately. So only while adding we consider one term. To conclude n + logn + nlogn will result to nlogn because that's the fastest growing.
Thank you sooo much!!! This is lit 🔥 . Yes, we need maybe a short video too for space complexity. Like what if 1 extra variable is used, 2 extra variables is used, what if a temp variable declaration & initialization is inside a for loop for n items, is there a O(log n) for space complexity and also best practises
Thanks a lot. And if you're using extra variables that are not related to n for example 5 extra variables then we say we're using constant space only. But if you use extra space inside a for loop that runs from 0 to n and you're declaring a new variable everytime then space complexity is O(n) but if you're using same variable then you've declared only once even if it is inside for loop in that case it's O(1). Will let you know more details about log n :)
@@codewithsimran9899 Thank you for your quick reply! Please bear with here for this example. Let's say we have a need of a temporary variable inside a for a loop. So declaring and initializing a variable inside for loop is a bad practice?like let temp; for(){ temp = something; //some operation with temp } or for(){ let temp = something; //some operation with temp } which one is fine? declaring temp outside or inside? just to cross verify what we have discussed.
What an explanation.. worderful 👏
You are a Gem
Thank you for the great explanation for time and space complexity please can you cover all the DS topics to make us understand in great way.. thank you once again
great explanation, for which scenario time complexity will be 0(nlogn)
If there are 2 loops nested where one has n complexity and another has logn it will get multipled and result to nlogn
@@codewithsimran9899 Thank you for the wonderful explanation.
In this case, when combining O(n) with O(logn), instead of O(nlogn) why cant we say it is O(n). O(n) has a bigger time compared to O(logn)
When you're multiplying complexities they become one entity for example n log n is one entity and n^2 is one entity so we can't separate them out because they're nested and one piece of the program. However when we're adding n + log n that time first one task ran whose time complexity is n and then another task ran whose time complexity is log n so we treat them separately. So only while adding we consider one term.
To conclude n + logn + nlogn will result to nlogn because that's the fastest growing.
@@codewithsimran9899 Okk I got it now! Thank you so much for your patience and support 🔥
Best explanation mam. Want a full series of DS and Algo.
Thanks, Mam! Awesome explanation
Very nice explanation of the concepts the. Concept of time complexity became very clear
Wow! Clear explanation and easy to understood in the video, thank you..
Want a video for space complexity
Please make a complete DSA series using js
Literally the best explanation mam 🧡
came to you by your insta posts.. really thank you
Thank you Aman :")
Thank you sooo much!!! This is lit 🔥 . Yes, we need maybe a short video too for space complexity. Like what if 1 extra variable is used, 2 extra variables is used, what if a temp variable declaration & initialization is inside a for loop for n items, is there a O(log n) for space complexity and also best practises
Thanks a lot. And if you're using extra variables that are not related to n for example 5 extra variables then we say we're using constant space only. But if you use extra space inside a for loop that runs from 0 to n and you're declaring a new variable everytime then space complexity is O(n) but if you're using same variable then you've declared only once even if it is inside for loop in that case it's O(1). Will let you know more details about log n :)
@@codewithsimran9899 Thank you for your quick reply!
Please bear with here for this example. Let's say we have a need of a temporary variable inside a for a loop.
So declaring and initializing a variable inside for loop is a bad practice?like
let temp;
for(){
temp = something;
//some operation with temp
}
or
for(){
let temp = something;
//some operation with temp
}
which one is fine? declaring temp outside or inside? just to cross verify what we have discussed.
It's not enough to find time complexities.. It's very basic. So if you can add some complex problems it will be helpful
Awesome explanation and very helpful.. video on space complexity would be more than great!!!!!
So easily understood everything Mam 😁
Glad to hear that 👍
Please make DSA in JavaScript video for placement (FAANG)
Great explanation. Can we Collab in a video? Both of our subscribers can learn something new then.
Js using ds??
ofcourse man