There is a chance of runtime error if length of size array is greater than greed array and all the children got cookies before the loop ends. Ex. g= {1,2}, s= {1,2,3}. We can insert if(r==n) return n; condition after the existing if condition or we can modify the while condition to (l
Striver, your DSA Sheet is absolutely phenomenal! It's been an invaluable resource for mastering data structures and algorithms. Looking forward to the remaining topics, especially the much-anticipated sections on strings and heaps. Thanks for all your hard work!
STARTED A2Z-DSA COURSE : ->STARTED IN JUNE 2023: RECURSION & BACKTRACKING TREES GRAPH DP ARRAYS BINARY SEARCH TILL OCTOBER COMPLETED ALL ABOVE TOPICS ? WAITED ONE MONTH? DECEMBER->LINKEDLIST FEBRUARY->BITMANIPULATION MARCH,APRIL->ADVANCE ARRAY TOPICS MAY->GREEDY STRING & STACK QUEUES ARE DONE BUT STILL WAITING FOR STRIVER TO LAUNCH IT AS WELL: WAITING FOR SYSTEM DESIGN & COMPETITIVE PROGRAMMING VIDEOS AS WELL THAT IS TAUGHT BY YOU THANK YOU SO MUCH FOR THIS AMAZING CONTENT (striver)?
bhiaya the code in the article is not correct ...it should have been this while (l < m && r < n) { // If the current cookie can // satisfy the current child's greed if (greed[r]
I was watching one of your sliding window videos, and mom saw you and said ki kitni kamzor h ye ladka , 😅😅😅😂😂😂, then I told my mom about you and your achievements.❤
thank u striver i've asked you many times.but finally the playlist is here.and also post stack and queue playlistand then please make more than 60 videos on greedy.Even my aim to hit the google.I hope you will help me out to crack it.
Alternate recursive solution in C++ class Solution { public: int findContentChildren(vector& g, vector& s) { sort(g.begin(), g.end()); sort(s.begin(), s.end()); return maxContentChildren(g, s, 0, 0); } private: int maxContentChildren(const vector& g, const vector& s, int i, int j) { if (i == g.size() || j == s.size()) { return i; } if (s[j] >= g[i]) { // Either we give the current cookie to the current child return maxContentChildren(g, s, i + 1, j + 1); } else { // Or we skip the current cookie return maxContentChildren(g, s, i, j + 1); } } };
So i just came here understand the question and able to do it myself: Here is the code : class Solution { public int findContentChildren(int[] g, int[] s) { Arrays.sort(g); Arrays.sort(s); int i = 0, j = 0, size1 = g.length, size2 = s.length, res = 0; while (i < size1 && j < size2) { if (g[i]
class Solution { public: int findContentChildren(vector& g, vector& s) { int m = g.size(); int n = s.size(); int l = 0, r = 0; sort(g.begin(), g.end()); sort(s.begin(), s.end()); while (r < m && l
Thankyou so much Striver for all you efforts throughout in delivering us so much valuable content. Any student / working professional can now be able to transition their career without paying money for courses. Would also like your insights on the point : While preparing for interviews most of the aspirants are going through the videos solely and solving the question after completely watching the video. And also are feeling lazy trying to solve the question on our own. What is the best way to complete any topic without being lazy and how should an aspirant approach any topic/playlist?
C++ solution of above video class Solution { public: int findContentChildren(vector& g, vector& s) { sort(g.begin(), g.end()); sort(s.begin(),s.end()); int left=0; int right=0; while(left
var findContentChildren = function (g, s) { s.sort((a, b) => a - b); g.sort((a, b) => a - b); let i = g.length - 1, j = s.length - 1, count = 0; while (i >= 0 && j >= 0) { if (s[j] >= g[i]) { j--; count++; } i--; } return count; };
cpp solution #include #include #include using namespace std; class Solution { public: int findContentChildren(vector& g, vector& s) { sort(g.begin(), g.end()); sort(s.begin(), s.end()); int ans = 0, i = 0, j = 0; int n = g.size(), m = s.size(); while (i < n && j < m) { if (s[j] >= g[i]) { ans++; i++; j++; } else { j++; } } return ans; } };
Guys. He'll release strings eventually don't worry. Let him chill. He's done more than enough for us already. Thank u so so much bro
Yeah We want it bro
There is a chance of runtime error if length of size array is greater than greed array and all the children got cookies before the loop ends. Ex. g= {1,2}, s= {1,2,3}. We can insert if(r==n) return n; condition after the existing if condition or we can modify the while condition to (l
Exactly. Thanks for pointing it out.
brother by doing simple change in the while code we can remove it indexoutofbound exception like: while(l
Striver, your DSA Sheet is absolutely phenomenal! It's been an invaluable resource for mastering data structures and algorithms. Looking forward to the remaining topics, especially the much-anticipated sections on strings and heaps.
Thanks for all your hard work!
bro why it's showing unauthorised after i sign in On takeuforward page
May be server issue
there is a correction in while loop put condition while(i
correction in while add one codition for r
Strings playlist please striver
Yup ++
Next wahii h
@@AkshitChaudhary-vx8iw aapko kaise pta bhai really. Shall I wait for it??
@@RajNamdev_19 striver ne tweet Kiya tha👍
@@AkshitChaudhary-vx8iw next stack and queue uske bad heap uske bad recursion aur last me string
Thank you so much striver for these priceless premium lectures.
Please release the strings series before the placement season begins.
The best thing about striver that no one talks about is that there are no adds on his channel in between
.
We need to add the condition (r
yes we should
Thank you sooo much @striver. Wanted this since long.....
Babe wake up! Another striver playlist dropped 🗣️🗣️
STARTED A2Z-DSA COURSE :
->STARTED IN JUNE 2023:
RECURSION & BACKTRACKING
TREES
GRAPH
DP
ARRAYS
BINARY SEARCH
TILL OCTOBER COMPLETED ALL ABOVE TOPICS ?
WAITED ONE MONTH?
DECEMBER->LINKEDLIST
FEBRUARY->BITMANIPULATION
MARCH,APRIL->ADVANCE ARRAY TOPICS
MAY->GREEDY
STRING & STACK QUEUES ARE DONE BUT STILL WAITING FOR STRIVER TO LAUNCH IT AS WELL:
WAITING FOR SYSTEM DESIGN & COMPETITIVE PROGRAMMING VIDEOS AS WELL THAT IS TAUGHT BY YOU
THANK YOU SO MUCH FOR THIS AMAZING CONTENT (striver)?
Yes sir, because of you we are doing extremely well 😊
Thank you so much ❤
strings playlist is the ultimate thing needed.
bhiaya the code in the article is not correct ...it should have been this while (l < m && r < n) {
// If the current cookie can
// satisfy the current child's greed
if (greed[r]
in the if statement , && r
I was watching one of your sliding window videos, and mom saw you and said ki kitni kamzor h ye ladka , 😅😅😅😂😂😂, then I told my mom about you and your achievements.❤
mom momy
My mom is like, why do you watch him so much? What is he even teaching you? Can you please go to sleep 🙁😂😂😂
@@mehekswe fr lol
mom is mom😁,my mom is planning to marry with him 😆striver if you reading , i 'd love to accept the offer🤪💌
@@Jyotigupta-vs4mz im better than striver
Most awaited playlist for me :)
Thank you so much! Was looking forward to greedy series
just a small correction in the while loop condition
while(l
thank u striver i've asked you many times.but finally the playlist is here.and also post stack and queue playlistand then please make more than 60 videos on greedy.Even my aim to hit the google.I hope you will help me out to crack it.
Update these links in the the sheet as well striver. This is great
Alternate recursive solution in C++
class Solution {
public:
int findContentChildren(vector& g, vector& s) {
sort(g.begin(), g.end());
sort(s.begin(), s.end());
return maxContentChildren(g, s, 0, 0);
}
private:
int maxContentChildren(const vector& g, const vector& s, int i, int j) {
if (i == g.size() || j == s.size()) {
return i;
}
if (s[j] >= g[i]) {
// Either we give the current cookie to the current child
return maxContentChildren(g, s, i + 1, j + 1);
} else {
// Or we skip the current cookie
return maxContentChildren(g, s, i, j + 1);
}
}
};
Strings playlist 💫
Thanks for another great video
Put string playlist also
So i just came here understand the question and able to do it myself:
Here is the code :
class Solution {
public int findContentChildren(int[] g, int[] s) {
Arrays.sort(g);
Arrays.sort(s);
int i = 0, j = 0, size1 = g.length, size2 = s.length, res = 0;
while (i < size1 && j < size2) {
if (g[i]
solved it before watching
String playlist please
vhaiya tusi great ho.. thanks alot ..🥰
Sir, strings playlist please
the first problem i solved before waching his vedio 😊
You are awesome bro thank you so much ❤
Lec 1 Done and Understood.
class Solution {
public:
int findContentChildren(vector& g, vector& s) {
int m = g.size();
int n = s.size();
int l = 0, r = 0;
sort(g.begin(), g.end());
sort(s.begin(), s.end());
while (r < m && l
Thanks
Thankyou so much Striver for all you efforts throughout in delivering us so much valuable content. Any student / working professional can now be able to transition their career without paying money for courses.
Would also like your insights on the point :
While preparing for interviews most of the aspirants are going through the videos solely and solving the question after completely watching the video. And also are feeling lazy trying to solve the question on our own. What is the best way to complete any topic without being lazy and how should an aspirant approach any topic/playlist?
Thank you 🙏
Bro is back 🤩🤩🥳
thanks sir the video was very helpful
understood, thanks for the video
I think there's a mistake in the A2Z DSA sheet. This question has been added to the "DP on Subsequences" portion, that too in HARD category lol...
why is video in the dynamic programming section on TUF
Bhai takeuforward ke greedy playlist ko please update kar do as along u make video .
Great content ❤
Is there any prerequesties to start this Greedy Algo's Playlist ??
help me out !!
class Solution {
public:
int findContentChildren(vector& g, vector& s) {
cin.tie(nullptr) -> sync_with_stdio(false);
sort(g.begin(),g.end());
sort(s.begin(),s.end());
int count = 0;
int p = 0; //g --> children
int q = 0; //s --> cookie
while(p
C++ solution of above video
class Solution {
public:
int findContentChildren(vector& g, vector& s) {
sort(g.begin(), g.end());
sort(s.begin(),s.end());
int left=0;
int right=0;
while(left
bhaiya please string ki nikal dijiye bhaut problem hoti solve karne me string me logic bhi nhi bnte please bhaiya
Is there a heaps playlist I am missing?
#striver heaps playlist is needed using Max heap within this week. Please....
y us this showing in a-z dp playlist????
please add link to this video in your a2z sheet, it is not there. only says coming soon
we want heap playlist...😊
🎉Thanks bro
yo yo my man is back
started today this playlist ......05/06/2024.....i will comment this comment when i complete this greedy algorithm series
var findContentChildren = function (g, s) {
s.sort((a, b) => a - b);
g.sort((a, b) => a - b);
let i = g.length - 1, j = s.length - 1, count = 0;
while (i >= 0 && j >= 0) {
if (s[j] >= g[i]) {
j--; count++;
}
i--;
}
return count;
};
Strings please
Greedy playlist making everyone Greedy for Strings
it should be l < m && r < n
Please string
You satisfied us
Best content ❤
Heap playlist please
Make playlist on heap
I easily think about that problem may be due to doing cp.
cpp solution
#include
#include
#include
using namespace std;
class Solution {
public:
int findContentChildren(vector& g, vector& s) {
sort(g.begin(), g.end());
sort(s.begin(), s.end());
int ans = 0, i = 0, j = 0;
int n = g.size(), m = s.size();
while (i < n && j < m) {
if (s[j] >= g[i]) {
ans++;
i++;
j++;
} else {
j++;
}
}
return ans;
}
};
Thanks sir
ty sir
int findContentChildren(vector& g, vector& s) {
int n=g.size(),m=s.size();
sort(g.begin(),g.end());
sort(s.begin(),s.end());
int r=0;
int l = 0;
while (r < n && l < m) {
if (g[r]
please bring the string video first .A humble request from us
thanks
Understood
stack and queue.........
btw thanks striver....................................................
Understood !!
ty
understood
19th of June 2024 I started Today
expected 😀😀
US
UnderStood
Doing like the video is important, my one like make 1K, your one like can make 100k;👍🏼👍🏼
UNderstood
Hii
❤
First
1 st view
can you change your outro song, its very cringe
Striver = Red Always
Thanks
Understood !!
Understood
understood
Understood
understood
Understood
Understood