sir it is good to understand from here and then write code by myself on LC. cos im not able to do the questions by myself at this time.(im able to solve maximum of the easy questions by myself)
@@sbmaurya09e it's okay, but prepare notes of questions you are not able to solve by your own and revise them in every 15 days, it will be very helpful
Sir can you please review this code , is this optimized or too brute force (or should've think it in another way) I am unable to think of equal distribution and remainder logic what steps should i take in mind to solve questions to think of optimized logic you've taken class Solution { public: vector missingRolls(vector& arr, int mean, int n) { int m = arr.size(); int sum_m = accumulate(arr.begin(), arr.end(), 0); int sum_n = mean * (m + n) - sum_m; if (sum_n < n || sum_n > 6 * n) return {}; int tr = (mean * n) - sum_n; vector res(n, mean); if (tr == 0) return res; if (tr < 0) { for (int i = 0; i < n; i++) { while (res[i] < 6) { tr++; res[i] += 1; if (tr == 0) return res; } } } else { for (int i = 0; i < n; i++) { while (res[i] > 1) { tr--; res[i] -= 1; if (tr == 0) return res; } } } return {}; } };
public int[] missingRolls(int[] rolls, int mean, int n) { int m = rolls.length; int sum = mean * (n+m); for(int i=0;i 0)){ return new int[0]; } for(int i=0;i0){ arr[i]++; r--; } } return arr; }
Like target for this video is 100.. please do like and subscribe😍
Great explanation
Good video man
Happy teacher's day sir
🎉🎉
Thanx for providing such a premium content
@@yashmatlani1976 thankyou ♥️
Happy teachers day to the most amazing Software Engineer whom I have been following
@@aayushvbw thankyou ♥️
Happy Teacher's day Sir ❤
@@Shaurya__Tripathi thankyou 😊
Happy Teachers Day My Daily Lecturer Saab..
@@manikantaalamanda3885 thankyou 😊
sir it is good to understand from here and then write code by myself on LC. cos im not able to do the questions by myself at this time.(im able to solve maximum of the easy questions by myself)
@@sbmaurya09e it's okay, but prepare notes of questions you are not able to solve by your own and revise them in every 15 days, it will be very helpful
Badhiya ❤❤
Happy Teachers day sir ❤
@@mr.nishantawasthi4402 thankyou 😊
Sir can you please review this code , is this optimized or too brute force (or should've think it in another way)
I am unable to think of equal distribution and remainder logic
what steps should i take in mind to solve questions to think of optimized logic you've taken
class Solution {
public:
vector missingRolls(vector& arr, int mean, int n) {
int m = arr.size();
int sum_m = accumulate(arr.begin(), arr.end(), 0);
int sum_n = mean * (m + n) - sum_m;
if (sum_n < n || sum_n > 6 * n) return {};
int tr = (mean * n) - sum_n;
vector res(n, mean);
if (tr == 0) return res;
if (tr < 0) {
for (int i = 0; i < n; i++) {
while (res[i] < 6) {
tr++;
res[i] += 1;
if (tr == 0)
return res;
}
}
} else {
for (int i = 0; i < n; i++) {
while (res[i] > 1) {
tr--;
res[i] -= 1;
if (tr == 0)
return res;
}
}
}
return {};
}
};
👏🏻
HAPPY Teahers day bhaiya 😊 bhaiya which pentab u use I want to purchase it if you can help
@@riddhiradia5888 XP Pen Deco 01 V2
@@shashwat_tiwari_st Thank you bhaiya your videos are very helpful
Happy teachers days guruji❤❤ ..i wish success ho kr aapko proud feel kraya ❤
@@shivambharti232 thankyou 😊
public int[] missingRolls(int[] rolls, int mean, int n) {
int m = rolls.length;
int sum = mean * (n+m);
for(int i=0;i 0)){
return new int[0];
}
for(int i=0;i0){
arr[i]++;
r--;
}
}
return arr;
}
Happy teachers' Day 💓
@@PiyushSharma-we8yd thankyou 😊