Number of Ways to Split Array | Simple Thought Process | Leetcode 2270 | codestorywithMIK

  Рет қаралды 5,172

codestorywithMIK

codestorywithMIK

Күн бұрын

Пікірлер: 120
@adityaparab4314
@adityaparab4314 4 күн бұрын
Happy Birthday to the best DSA teacher on youtube!
@aws_handles
@aws_handles 5 күн бұрын
Happy Birthday to the 🐐 Goat of DSA teaching ❤
@Mohit_Q
@Mohit_Q 5 күн бұрын
kon bola aaj birthday hai ?
@dchennaraidu
@dchennaraidu 5 күн бұрын
Linkedin
@AyushKumar-e5j1v
@AyushKumar-e5j1v 4 күн бұрын
Ane waale Samy me youtube ke sabse history creator teacher hone wale ho sir ❤
@prathameshpalkar514
@prathameshpalkar514 5 күн бұрын
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🥳🥳
@riteshhhhh_01
@riteshhhhh_01 4 күн бұрын
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 ✨
@aripact
@aripact 4 күн бұрын
Happy Birthday Bhaiya!!!❤❤❤
@tushar404
@tushar404 4 күн бұрын
Khud ho gaya bhaiya Starting after endsem again after 17 days gap Good confidence booster!!☺☺☺☺☺
@slagnajit4476
@slagnajit4476 4 күн бұрын
Happy birthday MIK bhaiya Thanks for every valuable add-ons❤🎉
@bhuppidhamii
@bhuppidhamii 5 күн бұрын
I'm so happy, I was able to do it myself. Thanku MIK😊
@AnshikaGupta-l1e
@AnshikaGupta-l1e 3 күн бұрын
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
@simply_akh1l
@simply_akh1l 4 күн бұрын
Happy Birthday Sir 🙏🏻
@NitishRaj-q3s
@NitishRaj-q3s 5 күн бұрын
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
@MystifiedBoy
@MystifiedBoy 4 күн бұрын
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 😍
@hellsterkun8764
@hellsterkun8764 5 күн бұрын
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
@sa_hilll94
@sa_hilll94 4 күн бұрын
Happy Birthday Sir, May god bless with more knowledge and support 😁🎂
@India_mera_sabkuch
@India_mera_sabkuch 4 күн бұрын
happy birthday GOAT ............you comes in my life where i need the most !!......sir please leetcode contest bhi solve karna start karoge kya aap?
@hellsterkun8764
@hellsterkun8764 5 күн бұрын
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.❤
@sumitgupta310
@sumitgupta310 4 күн бұрын
Happy Birthday bhaiya 🍾🥳
@salmaniproductions1104
@salmaniproductions1104 4 күн бұрын
Happy Birthday bhaiyya.
@Anshul-qb2pm
@Anshul-qb2pm 5 күн бұрын
happy birthday sir
@11csepratikshaargulewar71
@11csepratikshaargulewar71 5 күн бұрын
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
@AbhijeetMuneshwar
@AbhijeetMuneshwar 4 күн бұрын
Respected MIK Sir, Happy Bithday 🥳🎂
@Playvish
@Playvish 4 күн бұрын
Happy Birthday 🥳 MIK bhaiya
@salmaniproductions1104
@salmaniproductions1104 4 күн бұрын
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.
@AliGatez
@AliGatez 4 күн бұрын
Happy birthday MIK bhaiya❤🎉/
@deepbendudebnath9612
@deepbendudebnath9612 4 күн бұрын
Happiest Birthday bhaiya
@manishgaming4638
@manishgaming4638 5 күн бұрын
Easy tha Solved on my own
@unknown47896
@unknown47896 5 күн бұрын
Happy Birthday to the GOAT of DSA❤❤❤❤
@arnabsarkar5245
@arnabsarkar5245 5 күн бұрын
Many many happy returns of the day bhaiya...
@HeetVichhivora
@HeetVichhivora 5 күн бұрын
Happiest birthday Mik bhai may God bless you with infinite success🎉🎉🎉🎉
@priyajaiwal8072
@priyajaiwal8072 4 күн бұрын
Happy New Year, Mazhar, and wish you a very happy birthday .Wish this year brings you more health, growth and fun. keep inspiring❤
@abhisheksingh-rz8nj
@abhisheksingh-rz8nj 5 күн бұрын
Happy Birthday Sir
@mokshgupta-mh3vu
@mokshgupta-mh3vu 4 күн бұрын
Happy Birthday bhya
@HarmanSingh-nw6ix
@HarmanSingh-nw6ix 4 күн бұрын
wishing you a very very happy birthday bhaiya , may god help you achieve all your dreams as you help us achieving ours...♥♥♥
@IRONMAN-co7qg
@IRONMAN-co7qg 4 күн бұрын
HAPPY BIRTHDAY SIR
@minshal7713
@minshal7713 4 күн бұрын
Happy birthday mik sir🎉🎂🎉
@arabindaparida4075
@arabindaparida4075 5 күн бұрын
Happy Birthday broh
@yashraj5898
@yashraj5898 5 күн бұрын
happy birthday sir, and please always include the brute force solution as it enhances the thinking ability of ours.
@aizad786iqbal
@aizad786iqbal 4 күн бұрын
Happy Birthday MIK...
@shreyabajaj4588
@shreyabajaj4588 5 күн бұрын
Happy Birthday Bhaiya ...
@hare_krishna8411
@hare_krishna8411 5 күн бұрын
bhaiya raadhe raadhe..❤❤
@abhisheksingh-rz8nj
@abhisheksingh-rz8nj 5 күн бұрын
Success is not final, failure is not fatal : its the courage to continue that counts.
@AbhishekKumar-hu2pz
@AbhishekKumar-hu2pz 5 күн бұрын
Happy Birthday bro god bless u
@storytv796
@storytv796 5 күн бұрын
Happy Birthday sir ji
@DevanshGupta-io7rl
@DevanshGupta-io7rl 5 күн бұрын
happy birthday bhaiya
@harshugamer7776
@harshugamer7776 5 күн бұрын
Happy Birthday 🥳
@bhuppidhamii
@bhuppidhamii 5 күн бұрын
Happy Birthday bhaiya ❤
@ayushmanbaghel7659
@ayushmanbaghel7659 5 күн бұрын
Happy Birthday GOAT for your subscribers ♥♥
@saminkhan125
@saminkhan125 5 күн бұрын
Wising you a very happy birthday MIK
@divanshurawat8998
@divanshurawat8998 4 күн бұрын
Happy Birthday Bhayia🥳
@shaikhanif7268
@shaikhanif7268 5 күн бұрын
Happy Birthday bhaiya🎉
@anshul3112_
@anshul3112_ 5 күн бұрын
Happy Birthday Sir❤️✨
@ch0c0_1
@ch0c0_1 5 күн бұрын
Waah mik bhai .. aaj mera bhi birthday h ... Happy birthday to us both❤
@aws_handles
@aws_handles 5 күн бұрын
Happy Birthday 🎉
@ch0c0_1
@ch0c0_1 5 күн бұрын
@@aws_handles thanks
@bhuppidhamii
@bhuppidhamii 5 күн бұрын
Happy Birthday 🎂
@mehranahmed3612
@mehranahmed3612 5 күн бұрын
happy birthday
@shubham76
@shubham76 5 күн бұрын
Happy Birthday 🎉 sir
@FanIQQuiz
@FanIQQuiz 5 күн бұрын
Happy Birthday Guruji 🎂✨
@TronGotNoChill
@TronGotNoChill 4 күн бұрын
Happy Birthday Boss❤
@m_fi8926
@m_fi8926 5 күн бұрын
HAPPY BIRTHDAY MIK
@godlovers5352
@godlovers5352 5 күн бұрын
Happy birthday sir ❤🎉
@rishabraj7432
@rishabraj7432 5 күн бұрын
Happy BD guru
@sumatheultimategirl7477
@sumatheultimategirl7477 5 күн бұрын
Happy Birthday mike🥳🥳🥳🥳💖💖
@vishwashsoni610
@vishwashsoni610 5 күн бұрын
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; } };
@himadrinath1502
@himadrinath1502 4 күн бұрын
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.
@aaronstn223
@aaronstn223 4 күн бұрын
Happy birthday mik
@thefinalfit
@thefinalfit 5 күн бұрын
Happy Birthday MIK 🎉
@kakshat22
@kakshat22 5 күн бұрын
Happpy birthday MIK bro ❤🎉
@gauravmundhada1647
@gauravmundhada1647 5 күн бұрын
Happy birthday❤
@joydeep-halder
@joydeep-halder 5 күн бұрын
Happy Birthday bhaiya 🎂🎂🎉🎉
@TheRUSHIZ
@TheRUSHIZ 4 күн бұрын
Happy Birthday Bhaiya!! can you please make a playlist of prefix sum
@shubhamsharma4353
@shubhamsharma4353 4 күн бұрын
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)
@SRoy2700
@SRoy2700 5 күн бұрын
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
@100solarmass
@100solarmass 5 күн бұрын
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; } }
@joydeep-halder
@joydeep-halder 5 күн бұрын
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]
@UTKARSHSHUKLAIIITT
@UTKARSHSHUKLAIIITT 5 күн бұрын
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
@harshitkaundal6373
@harshitkaundal6373 3 күн бұрын
Happy Birthday Bro, Sorry late hogya
@AyushKumar-e5j1v
@AyushKumar-e5j1v 4 күн бұрын
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
@imPriyansh77
@imPriyansh77 4 күн бұрын
Prefix Sum - Easy Problem
@YogeshShinde-l4b
@YogeshShinde-l4b 4 күн бұрын
Vote for Mike DSA sheet
@DevanshGupta-io7rl
@DevanshGupta-io7rl 5 күн бұрын
int waysToSplitArray(vector& nums) { int n=nums.size(),cnt=0; vectorprefsum(n); prefsum[0]=nums[0]; for(int i=1;i
@sauravchandra10
@sauravchandra10 4 күн бұрын
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! ❤
@AnkushKaudi
@AnkushKaudi 4 күн бұрын
Saw today's problem statement, figured out the optimal solution in
@Amanbiragi17
@Amanbiragi17 5 күн бұрын
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
@ishikacasley2786
@ishikacasley2786 4 күн бұрын
//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; } };
@jeehub041
@jeehub041 5 күн бұрын
Bhaiya kya isse one pass me bhi kia jaa sakta ha like without calculating total sum initially?
@universalcosmologist3675
@universalcosmologist3675 4 күн бұрын
bro pls make video on line sweep algorithm plssss i request 🙏🙏🙏🙏🙏🙏🙏🙏
@gui-codes
@gui-codes 5 күн бұрын
Sir aaj Birthday me to rest karlo 😅. Happy Birthday Legend ❤
@Dnsndy
@Dnsndy 5 күн бұрын
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; } };
@prajwalshaw9217
@prajwalshaw9217 4 күн бұрын
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.
@sayyedrehan-y1j
@sayyedrehan-y1j 4 күн бұрын
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.
@arjunkumaryadav8102
@arjunkumaryadav8102 4 күн бұрын
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
@Vibhanshushrivastava
@Vibhanshushrivastava 3 күн бұрын
sir please leetcode 3409 , its a biweekly 147 contest question, kch smjh ni pdrha kya hua isme , pretty hard question i would say
@DevanshGupta-io7rl
@DevanshGupta-io7rl 5 күн бұрын
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
@B-Billy
@B-Billy 5 күн бұрын
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; } }
@algosafari
@algosafari 4 күн бұрын
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
@gauravparasar4571
@gauravparasar4571 4 күн бұрын
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
@akashsahoo2421
@akashsahoo2421 3 күн бұрын
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.
@girlwithwings4903
@girlwithwings4903 5 күн бұрын
silly doubt - abhi bhi to loop do baar cahl raha hai to TC n2 kyu nhi hai 😐
@algosafari
@algosafari 5 күн бұрын
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
@AyushKumar-e5j1v
@AyushKumar-e5j1v 4 күн бұрын
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 🙏🙏🙏
@Rahulkumar-bn4tk
@Rahulkumar-bn4tk 5 күн бұрын
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
@shresthgupta2670
@shresthgupta2670 5 күн бұрын
Bro koi problem nahi bass time invest karte rahoo in learning, kuch din baad ABCD jaise hoo jae gaa
@Rahulkumar-bn4tk
@Rahulkumar-bn4tk 4 күн бұрын
@@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 :(
@shresthgupta2670
@shresthgupta2670 3 күн бұрын
@@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
@RohitKumar-dz8dh
@RohitKumar-dz8dh 5 күн бұрын
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
@crazygamerrohan9899
@crazygamerrohan9899 5 күн бұрын
Did by my own optimally🤎
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
How to Start LeetCode from ZERO in 2025
11:31
Ashish Pratap Singh
Рет қаралды 47 М.
Prefix Sum in 4 minutes | LeetCode Pattern
4:13
AlgoMasterIO
Рет қаралды 13 М.
go is great i hate it
14:44
SST
Рет қаралды 28 М.
one year of studying (it was a mistake)
12:51
Jeffrey Codes
Рет қаралды 55 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 709 М.