Today's quote form my side:- "Be stronger than your stronger excuses, embrace the toughness, discipline and accept those pains because that is how you are going to built yourself", love your explainations MIK ✨
I was able to do it myself, ty MIK Sir. I did with cumulative Sum and reverse cumulative sum and now I'm here for more clarity with your story. Happy Birthday Sir🥳🥳
Happy Birthday MIK BHAIYA! Brute force: class Solution { public: int waysToSplitArray(vector& nums) { int n = nums.size(); int split = 0; for(int i=0; i
Happy Birthday Mik Sir! Aaj bhi aapne aap hi solve ho gaya question: class Solution { public: int waysToSplitArray(vector& nums) { int n = nums.size(); long long sum = 0; int ans = 0; for (int i = 0; i < n; i++) { sum += nums[i]; } long long psum = 0; for (int i = 0; i < n - 1; i++) { psum += nums[i]; if (sum - psum
Happy Birthday bhaiyaa ♥️ god bless you and may all your wishes come true and may God flood your life with happiness and all blessings always keep smiling 😊 Thanks for everything 😍
Sir koi bola hai maine 150 q? Kiye hai koi bolta hai 200 q? Kite ayr vo google microsoft main h Bt hme to jyada q? Ladta hai main demotivate ho jata hu kya kru?; sir video bana ke explain kr do i m your 1'st subscriber please sir
this is how i solved this question : TC: O(n) SC: O(n) class Solution { public: int waysToSplitArray(vector& nums) { int n = nums.size(); vectorprefixSum(n,0); prefixSum[0]=nums[0]; for(int i=1;i=0;i--){ suffixSum[i] = suffixSum[i+1]+nums[i]; } int count = 0; for(int i=0;i= suffixSum[i+1]){ count++; } } return count; } };
class SegmentTree { public: vector segTree; int n; SegmentTree(vector& nums) { n = nums.size(); segTree.resize(4 * n); buildTree(nums, 0, n - 1, 0); } void buildTree(vector& nums, int start, int end, int index) { if (start == end) { segTree[index] = nums[start]; return; } int mid = start + (end - start) / 2; buildTree(nums, start, mid, 2 * index + 1); buildTree(nums, mid + 1, end, 2 * index + 2); segTree[index] = segTree[2 * index + 1] + segTree[2 * index + 2]; } long long query(int start, int end, int left, int right, int index) { if (start > right || end < left) return 0; if (start >= left && end = rightSum) split++; } return split; } }; my solution using segment tree.
Hats off, sir, for your unmatched dedication, working tirelessly even on your birthday. Your commitment is true inspiration! Rest assured, I’ll always credit you for the success ahead.❤
Solved by own, here is my code - int waysToSplitArray(vector& nums) { int ans =0; long long whole_sum = 0; long long sum=0; for(int x:nums) whole_sum+=x;
for(int i=0;i=whole_sum) ans++; } return ans; } Thank you so much bhaiyya.
class Solution { public: int waysToSplitArray(vector& nums) { vector prefixSum; long sum = 0; for(auto it : nums){ sum += it; prefixSum.push_back(sum); } int n = nums.size(); int count = 0; for(int i = 0; i < n-1; i++){ if(prefixSum[i] >= prefixSum[n-1]-prefixSum[i]) count++; } return count; } }; //T.C->O(n) //S.C.->O(n)
C++ code of Prefix Sum Approach: class Solution { public: int waysToSplitArray(vector& nums) { int n = nums.size(); vectorprefixSum(n); prefixSum[0] = nums[0]; for(int i =1;i
Aj ka question easy mark hona chahiye tha 😅. I've derived one more equation. we can directly check if( 2*leftSum >= totalSum). [ Basically leftSum >= totalSum/2]
Python implementation: class Solution: def waysToSplitArray(self, nums: List[int]) -> int: totSum = sum(nums) preSum = 0 cnt = 0 for i in range(len(nums)-1): preSum += nums[i] if preSum >= totSum - preSum: cnt += 1 return cnt A happy new year and a very happy birthday to you! ❤
Using PrefixSum of the Array public int waysToSplitArray(int[] arr) { int n = arr.length; long[] prefSum = new long[n]; prefSum[0]=arr[0]; for(int i=1;i
//using prefix sum Array class Solution { public: int waysToSplitArray(vector& nums) { int n = nums.size(); vector prefix(n); prefix[0] = nums[0]; for (int i = 1; i < n; i++) { prefix[i] = prefix[i - 1] + nums[i]; } long long leftSum = 0; long long rightSum = 0; int count = 0; for (int i = 0; i < n - 1; i++) { leftSum = prefix[i]; rightSum = prefix[n - 1] - leftSum; if (leftSum >= rightSum) { count++; } } return count; } };
Happy Birthday bhaiya ,,, May MataRani Mahadev Bless U Whenever i see your video bhaiya i get to know more optimise solutions I submitted the solution with space complexity : O(n) using prefix array class Solution { public: int waysToSplitArray(vector& v) { int n = v.size(); long long preSum = 0; vector pre(n, 0); for(int i = 0; i < n; i++) { preSum += v[i]; pre[i] = preSum; } int ans = 0; for(int i = 0; i < n - 1; i++) { if(pre[i] >= (pre[n - 1] - pre[i])) ans++; } return ans; } };
Bhaiya i have a doubt please solve, should i directly use your topic wise playlist to solve problems, i am a bit confused. Is it good to solve problems from your playlists, i will solve problem by my own first then watch the solution from your video, is that good or there is any better approach.
typedef long long ll; int waysToSplitArray(vector& nums) { int n=nums.size(); int cnt=0; ll sum=accumulate(nums.begin(),nums.end(),0ll); ll Lsum=0; ll Rsum=0; for(int i=0;i=Rsum) cnt++; } return cnt; } ho gya accumulate mai fasa tha nayi cheez seekh lii aaj 0ll lagana zaruri hai
Hello sir. Can u make a video on LC 3404...count special subsequences. This question was asked in LC weekly last week and this problem was also asked in Google OA. It would be a great help if u could make a video on this particular question. Thank u.
Java Solution Using Prefix Sum class Solution { long[] prefixSum; public int waysToSplitArray(int[] nums) { int n = nums.length; prefixSum = new long[n]; int count = 0; long totalSum = nums[0]; prefixSum[0] = nums[0]; for(int i=1; i= rSum) count++; } return count; } }
Bhaiya mere vlg me company nahi aati hai ...muje kya karna chahiye aur jyada project par bhi kam nahi karta hu ..but DSA ata hai jo kuch bhi aap se seekha hai bus utna hi aata hai
Sir log bolte hai main 150 kiya koi bola hai 300 kiya aur google meta amazone hai is wakt bt hame kyu jyada q? Lag rhe hai solve krne ko mera consept clear hota hai apke video se kya aap video bna ke bata sakte ho 2025 me mujhe bhi mncs jana hai jo apse hi possible hai 🙏🙏🙏
sir maine first wale code bhi try kiya but usse TLE aa ja rha h class Solution { public: int waysToSplitArray(vector& nums) { int splitCount =0; for (int i =0 ;i
bro can you make a video on gfg today potd(04-01-25) ,i.e on Count all triplets with given sum in sorted array, its different from the simply counting the triplets that sum to the target,because here we have to count to the duplicates also,no proper video is available on youtube.
@@shresthgupta2670 bro like bht din ho gaye hai almost maine 180 problem solve kar chuka huaa like tab v problem bht hote hai like her ek problem meh stuck hp jata hu :(
@@Rahulkumar-bn4tkhaa i know is solved many questions but still stuck , only one thing we do practice practice practices its like integration we do in school
Many many happy returns of the day to my Poineer 🙇🙇🙇. here is your given task for this problem--> int n = nums.length; long prefix[] = new long[n]; int split = 0; //populate prefix sum array prefix[0] = nums[0]; for(int i=1;i
Happy Birthday to the best DSA teacher on youtube!
Happy Birthday Bhaiya!!!❤❤❤
Happy Birthday to the 🐐 Goat of DSA teaching ❤
kon bola aaj birthday hai ?
Linkedin
Ane waale Samy me youtube ke sabse history creator teacher hone wale ho sir ❤
Happy birthday mik sir🎉🎂🎉
Today's quote form my side:- "Be stronger than your stronger excuses, embrace the toughness, discipline and accept those pains because that is how you are going to built yourself", love your explainations MIK ✨
Respected MIK Sir,
Happy Bithday 🥳🎂
I was able to do it myself, ty MIK Sir. I did with cumulative Sum and reverse cumulative sum and now I'm here for more clarity with your story. Happy Birthday Sir🥳🥳
Happy birthday MIK bhaiya
Thanks for every valuable add-ons❤🎉
Khud ho gaya bhaiya
Starting after endsem again after 17 days gap
Good confidence booster!!☺☺☺☺☺
Happy Birthday bhaiya 🍾🥳
happy birthday sir thank you so much for your efforts to explain a problem in such a easy way,you are such a amazing teacher of dsa
Happy Birthday Sir 🙏🏻
Happy birthday MIK bhaiya❤🎉/
Happy Birthday bhaiyya.
Happy Birthday 🥳 MIK bhaiya
I'm so happy, I was able to do it myself. Thanku MIK😊
Happy Birthday Sir, May god bless with more knowledge and support 😁🎂
Happy Birthday MIK BHAIYA!
Brute force:
class Solution {
public:
int waysToSplitArray(vector& nums) {
int n = nums.size();
int split = 0;
for(int i=0; i
Easy tha
Solved on my own
Happy New Year, Mazhar, and wish you a very happy birthday .Wish this year brings you more health, growth and fun. keep inspiring❤
Happy Birthday MIK...
Happy Birthday Mik Sir!
Aaj bhi aapne aap hi solve ho gaya question:
class Solution {
public:
int waysToSplitArray(vector& nums) {
int n = nums.size();
long long sum = 0;
int ans = 0;
for (int i = 0; i < n; i++) {
sum += nums[i];
}
long long psum = 0;
for (int i = 0; i < n - 1; i++) {
psum += nums[i];
if (sum - psum
Happy Birthday bhya
happy birthday sir
Happy Birthday broh
Happy Birthday bhaiyaa ♥️ god bless you and may all your wishes come true and may God flood your life with happiness and all blessings always keep smiling 😊 Thanks for everything 😍
Happy birthday mik
HAPPY BIRTHDAY SIR
Happiest Birthday bhaiya
Sir koi bola hai maine 150 q? Kiye hai koi bolta hai 200 q? Kite ayr vo google microsoft main h Bt hme to jyada q? Ladta hai main demotivate ho jata hu kya kru?; sir video bana ke explain kr do i m your 1'st subscriber please sir
HAPPY BIRTHDAY MIK
Happy Birthday Boss❤
Happy Birthday Sir❤️✨
happy birthday GOAT ............you comes in my life where i need the most !!......sir please leetcode contest bhi solve karna start karoge kya aap?
Success is not final, failure is not fatal : its the courage to continue that counts.
bhaiya raadhe raadhe..❤❤
Happy Birthday Bhayia🥳
Happy Birthday Sir
Happy Birthday 🥳
Happy Birthday MIK 🎉
Happiest birthday Mik bhai may God bless you with infinite success🎉🎉🎉🎉
Happy BD guru
Happy Birthday 🎉 sir
Many many happy returns of the day bhaiya...
Happy Birthday to the GOAT of DSA❤❤❤❤
Happy Birthday mike🥳🥳🥳🥳💖💖
Happy Birthday sir ji
O lord, bless him in this day and in all the days of his life and grant him a long life .amen 🙏 happy birthday MIK sir
Happy birthday sir ❤🎉
Happy Birthday Guruji 🎂✨
this is how i solved this question :
TC: O(n)
SC: O(n)
class Solution {
public:
int waysToSplitArray(vector& nums) {
int n = nums.size();
vectorprefixSum(n,0);
prefixSum[0]=nums[0];
for(int i=1;i=0;i--){
suffixSum[i] = suffixSum[i+1]+nums[i];
}
int count = 0;
for(int i=0;i= suffixSum[i+1]){
count++;
}
}
return count;
}
};
class SegmentTree {
public:
vector segTree;
int n;
SegmentTree(vector& nums) {
n = nums.size();
segTree.resize(4 * n);
buildTree(nums, 0, n - 1, 0);
}
void buildTree(vector& nums, int start, int end, int index) {
if (start == end) {
segTree[index] = nums[start];
return;
}
int mid = start + (end - start) / 2;
buildTree(nums, start, mid, 2 * index + 1);
buildTree(nums, mid + 1, end, 2 * index + 2);
segTree[index] = segTree[2 * index + 1] + segTree[2 * index + 2];
}
long long query(int start, int end, int left, int right, int index) {
if (start > right || end < left) return 0;
if (start >= left && end = rightSum) split++;
}
return split;
}
};
my solution using segment tree.
Hats off, sir, for your unmatched dedication, working tirelessly even on your birthday. Your commitment is true inspiration!
Rest assured, I’ll always credit you for the success ahead.❤
Happy Birthday bro
god bless u
Happy Birthday bhaiya ❤
Solved by own, here is my code -
int waysToSplitArray(vector& nums) {
int ans =0;
long long whole_sum = 0;
long long sum=0;
for(int x:nums)
whole_sum+=x;
for(int i=0;i=whole_sum)
ans++;
}
return ans;
}
Thank you so much bhaiyya.
Happy Birthday GOAT for your subscribers ♥♥
Happy Birthday bhaiya🎉
wishing you a very very happy birthday bhaiya , may god help you achieve all your dreams as you help us achieving ours...♥♥♥
Waah mik bhai .. aaj mera bhi birthday h ... Happy birthday to us both❤
Happy Birthday 🎉
@@aws_handles thanks
Happy Birthday 🎂
happy birthday
happy birthday bhaiya
Happy birthday❤
Happy Birthday Bhaiya ...
Wising you a very happy birthday MIK
class Solution {
public:
int waysToSplitArray(vector& nums) {
vector prefixSum;
long sum = 0;
for(auto it : nums){
sum += it;
prefixSum.push_back(sum);
}
int n = nums.size();
int count = 0;
for(int i = 0; i < n-1; i++){
if(prefixSum[i] >= prefixSum[n-1]-prefixSum[i])
count++;
}
return count;
}
};
//T.C->O(n)
//S.C.->O(n)
happy birthday sir, and please always include the brute force solution as it enhances the thinking ability of ours.
Happpy birthday MIK bro ❤🎉
Happy Birthday bhaiya 🎂🎂🎉🎉
Happy Birthday Bro, Sorry late hogya
Happy Birthday Bhaiya!! can you please make a playlist of prefix sum
Approach 1: with prefixSum tc: O(N) SC:O(N)
class Solution {
public:
int waysToSplitArray(vector& nums) {
vector preFix(nums.size());
preFix[0] = nums[0];
for(int i=1 ;i
C++ code of Prefix Sum Approach:
class Solution {
public:
int waysToSplitArray(vector& nums) {
int n = nums.size();
vectorprefixSum(n);
prefixSum[0] = nums[0];
for(int i =1;i
Aj ka question easy mark hona chahiye tha 😅. I've derived one more equation. we can directly check if( 2*leftSum >= totalSum). [ Basically leftSum >= totalSum/2]
class Solution:
def waysToSplitArray(self, nums: List[int]) -> int:
total_Sum, count, l_sum = sum(nums), 0, 0
for i in range(len(nums) - 1):
l_sum += nums[i]
total_Sum -= nums[i]
if l_sum >= total_Sum:
count += 1
return count
```java[]
class Solution {
public int waysToSplitArray(int[] nums) {
int cnt = 0;
long rSum = 0;
long lSum = 0;
for (int i = 0; i < nums.length; i++) {
rSum += nums[i];
}
for (int i = 0; i < nums.length - 1; i++) {
lSum += nums[i];
rSum -= nums[i];
if (lSum >= rSum)
cnt++;
}
return cnt;
}
}
Python implementation:
class Solution:
def waysToSplitArray(self, nums: List[int]) -> int:
totSum = sum(nums)
preSum = 0
cnt = 0
for i in range(len(nums)-1):
preSum += nums[i]
if preSum >= totSum - preSum:
cnt += 1
return cnt
A happy new year and a very happy birthday to you! ❤
bro pls make video on line sweep algorithm plssss i request 🙏🙏🙏🙏🙏🙏🙏🙏
Using PrefixSum of the Array
public int waysToSplitArray(int[] arr) {
int n = arr.length;
long[] prefSum = new long[n];
prefSum[0]=arr[0];
for(int i=1;i
int waysToSplitArray(vector& nums) {
int n=nums.size(),cnt=0;
vectorprefsum(n);
prefsum[0]=nums[0];
for(int i=1;i
Sir aaj Birthday me to rest karlo 😅.
Happy Birthday Legend ❤
Prefix Sum - Easy Problem
//using prefix sum Array
class Solution {
public:
int waysToSplitArray(vector& nums) {
int n = nums.size();
vector prefix(n);
prefix[0] = nums[0];
for (int i = 1; i < n; i++) {
prefix[i] = prefix[i - 1] + nums[i];
}
long long leftSum = 0;
long long rightSum = 0;
int count = 0;
for (int i = 0; i < n - 1; i++) {
leftSum = prefix[i];
rightSum = prefix[n - 1] - leftSum;
if (leftSum >= rightSum) {
count++;
}
}
return count;
}
};
Happy Birthday bhaiya ,,, May MataRani Mahadev Bless U
Whenever i see your video bhaiya i get to know more optimise solutions
I submitted the solution with space complexity : O(n) using prefix array
class Solution {
public:
int waysToSplitArray(vector& v) {
int n = v.size();
long long preSum = 0;
vector pre(n, 0);
for(int i = 0; i < n; i++)
{
preSum += v[i];
pre[i] = preSum;
}
int ans = 0;
for(int i = 0; i < n - 1; i++)
{
if(pre[i] >= (pre[n - 1] - pre[i]))
ans++;
}
return ans;
}
};
Bhaiya i have a doubt please solve, should i directly use your topic wise playlist to solve problems, i am a bit confused. Is it good to solve problems from your playlists, i will solve problem by my own first then watch the solution from your video, is that good or there is any better approach.
Bhaiya kya isse one pass me bhi kia jaa sakta ha like without calculating total sum initially?
Saw today's problem statement, figured out the optimal solution in
typedef long long ll;
int waysToSplitArray(vector& nums) {
int n=nums.size();
int cnt=0;
ll sum=accumulate(nums.begin(),nums.end(),0ll);
ll Lsum=0;
ll Rsum=0;
for(int i=0;i=Rsum) cnt++;
}
return cnt;
} ho gya accumulate mai fasa tha nayi cheez seekh lii aaj 0ll lagana zaruri hai
Hello sir. Can u make a video on LC 3404...count special subsequences. This question was asked in LC weekly last week and this problem was also asked in Google OA. It would be a great help if u could make a video on this particular question. Thank u.
Vote for Mike DSA sheet
Java Solution Using Prefix Sum
class Solution {
long[] prefixSum;
public int waysToSplitArray(int[] nums) {
int n = nums.length;
prefixSum = new long[n];
int count = 0;
long totalSum = nums[0];
prefixSum[0] = nums[0];
for(int i=1; i= rSum)
count++;
}
return count;
}
}
Bhaiya mere vlg me company nahi aati hai ...muje kya karna chahiye aur jyada project par bhi kam nahi karta hu ..but DSA ata hai jo kuch bhi aap se seekha hai bus utna hi aata hai
Sir log bolte hai main 150 kiya koi bola hai 300 kiya aur google meta amazone hai is wakt bt hame kyu jyada q? Lag rhe hai solve krne ko mera consept clear hota hai apke video se kya aap video bna ke bata sakte ho 2025 me mujhe bhi mncs jana hai jo apse hi possible hai 🙏🙏🙏
sir maine first wale code bhi try kiya but usse TLE aa ja rha h
class Solution {
public:
int waysToSplitArray(vector& nums) {
int splitCount =0;
for (int i =0 ;i
sir please leetcode 3409 , its a biweekly 147 contest question, kch smjh ni pdrha kya hua isme , pretty hard question i would say
bro can you make a video on gfg today potd(04-01-25) ,i.e on Count all triplets with given sum in sorted array, its different from the simply counting the triplets that sum to the target,because here we have to count to the duplicates also,no proper video is available on youtube.
bhiyaa aaj agya h oa ka link 5 din hai abhi dene k liye to kya kya prep kru plsssss help krdo pehli br dunga mujhe dar lagra hai
Sir ek aur question tha aapne el for loop bahar aur ek and use kiya h to tc to abi bhi 0(N^2) hogi na
someone pls clear my doubt
silly doubt - abhi bhi to loop do baar cahl raha hai to TC n2 kyu nhi hai 😐
Bhaiya Mare se Question Nhi ban Paaa rhe almost mere DSA karte huyee 6 to 7 month ho chuke hai .. bhaiya kya karu ... kaise practice karu
Bro koi problem nahi bass time invest karte rahoo in learning, kuch din baad ABCD jaise hoo jae gaa
@@shresthgupta2670 bro like bht din ho gaye hai almost maine 180 problem solve kar chuka huaa like tab v problem bht hote hai like her ek problem meh stuck hp jata hu :(
@@Rahulkumar-bn4tkhaa i know is solved many questions but still stuck , only one thing we do practice practice practices its like integration we do in school
Many many happy returns of the day to my Poineer 🙇🙇🙇. here is your given task for this problem-->
int n = nums.length;
long prefix[] = new long[n];
int split = 0;
//populate prefix sum array
prefix[0] = nums[0];
for(int i=1;i
Did by my own optimally🤎