→ so you are an awesome parent and want to give your children some cookies, but you…
- User
→ so you are an awesome parent and want to give your children some cookies, but you should give each child at most one cookie *** at most one cookie ***
→ each child “i” has a greed factor “g[i]”, which is the minimum size of a cookie that the child will be content with, *** you know *** the minimum number of cookies that a child will be satisfied with okay
→ also you are given a list of cookie where cooki j has a size “s[j]” if s[j] >= g[i] “ $
→ we can assign the cookie “j” to the child “i” and the child “i” will be content , Your goal is to maximize the number of your content children and output the max the number of cookie
Q- so we have this input : g= [1,2,3] and s=[1,1]
Give we have 3 kids where
The first child had a grid factor of 1 : in the other word we need 1 kindy to make it happy The second child had a grid factor of 2 : in other word we need 2 kindies to make it happy The third child had a grid factor of 3 : in other word we need 3 kindes to make it happy
But we have 2 type of kandies with quantities equal 1 and 1 for these two oky
So based on the problem description and this example we can statfify only one kid who is the first one oky
Q- in the second example : g=[1,2] and s=[1,2,3]
So we have 2 children and 3 cookies : the greed factors of 2 children are 1 , 2 → so you have 3 cookies and their sizes are big enough to gratify all of the children
Q- what is the assigned condition here?
—> is to build to find a cookie j where the size s[j] if >= then g[i]
Q- using the problem can who have one potential solution to iterate over it?
First, I think we need to sort the second input array and the first one also
Then I think we need to iterate through the both array
Fix the first element each time the first array and compare it with all the cookie size
If we find one that >= then it We increment our counter by one
Fix the grid of the next child and compare it with the other kindes removing the assigned cookie if it’s possible
And keep going oky
Q- give a feedback about my thinking process so, far without give me the actuacal solution just give some guinness question to make me think deeply about the solution and guide my search oky
- Assistant