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

Поделиться
HTML-код
  • Опубликовано: 4 янв 2025

Комментарии • 120

  • @adityaparab4314
    @adityaparab4314 День назад +8

    Happy Birthday to the best DSA teacher on youtube!

  • @aripact
    @aripact День назад +1

    Happy Birthday Bhaiya!!!❤❤❤

  • @aws_handles
    @aws_handles 2 дня назад +20

    Happy Birthday to the 🐐 Goat of DSA teaching ❤

  • @AyushKumar-e5j1v
    @AyushKumar-e5j1v День назад +4

    Ane waale Samy me youtube ke sabse history creator teacher hone wale ho sir ❤

  • @minshal7713
    @minshal7713 День назад +1

    Happy birthday mik sir🎉🎂🎉

  • @riteshhhhh_01
    @riteshhhhh_01 День назад

    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 ✨

  • @AbhijeetMuneshwar
    @AbhijeetMuneshwar День назад +2

    Respected MIK Sir,
    Happy Bithday 🥳🎂

  • @prathameshpalkar514
    @prathameshpalkar514 2 дня назад +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🥳🥳

  • @slagnajit4476
    @slagnajit4476 День назад +4

    Happy birthday MIK bhaiya
    Thanks for every valuable add-ons❤🎉

  • @tushar404
    @tushar404 День назад +3

    Khud ho gaya bhaiya
    Starting after endsem again after 17 days gap
    Good confidence booster!!☺☺☺☺☺

  • @sumitgupta310
    @sumitgupta310 День назад +1

    Happy Birthday bhaiya 🍾🥳

  • @AnshikaGupta-l1e
    @AnshikaGupta-l1e День назад +1

    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 День назад +3

    Happy Birthday Sir 🙏🏻

  • @AliGatez
    @AliGatez День назад +1

    Happy birthday MIK bhaiya❤🎉/

  • @salmaniproductions1104
    @salmaniproductions1104 2 дня назад +1

    Happy Birthday bhaiyya.

  • @Playvish
    @Playvish День назад +1

    Happy Birthday 🥳 MIK bhaiya

  • @bhuppidhamii
    @bhuppidhamii 2 дня назад +4

    I'm so happy, I was able to do it myself. Thanku MIK😊

  • @sa_hilll94
    @sa_hilll94 День назад +1

    Happy Birthday Sir, May god bless with more knowledge and support 😁🎂

  • @NitishRaj-q3s
    @NitishRaj-q3s 2 дня назад +3

    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

  • @manishgaming4638
    @manishgaming4638 2 дня назад +1

    Easy tha
    Solved on my own

  • @priyajaiwal8072
    @priyajaiwal8072 День назад +1

    Happy New Year, Mazhar, and wish you a very happy birthday .Wish this year brings you more health, growth and fun. keep inspiring❤

  • @aizad786iqbal
    @aizad786iqbal День назад +1

    Happy Birthday MIK...

  • @hellsterkun8764
    @hellsterkun8764 2 дня назад +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

  • @mokshgupta-mh3vu
    @mokshgupta-mh3vu День назад +1

    Happy Birthday bhya

  • @Anshul-qb2pm
    @Anshul-qb2pm 2 дня назад +2

    happy birthday sir

  • @arabindaparida4075
    @arabindaparida4075 2 дня назад +1

    Happy Birthday broh

  • @MystifiedBoy
    @MystifiedBoy День назад +2

    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 😍

  • @aaronstn223
    @aaronstn223 2 дня назад +1

    Happy birthday mik

  • @IRONMAN-co7qg
    @IRONMAN-co7qg День назад +1

    HAPPY BIRTHDAY SIR

  • @deepbendudebnath9612
    @deepbendudebnath9612 День назад +1

    Happiest Birthday bhaiya

  • @AyushKumar-e5j1v
    @AyushKumar-e5j1v День назад +2

    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

  • @m_fi8926
    @m_fi8926 2 дня назад +1

    HAPPY BIRTHDAY MIK

  • @TronGotNoChill
    @TronGotNoChill День назад

    Happy Birthday Boss❤

  • @anshul3112_
    @anshul3112_ 2 дня назад +1

    Happy Birthday Sir❤️✨

  • @India_mera_sabkuch
    @India_mera_sabkuch День назад +1

    happy birthday GOAT ............you comes in my life where i need the most !!......sir please leetcode contest bhi solve karna start karoge kya aap?

  • @abhisheksingh-rz8nj
    @abhisheksingh-rz8nj 2 дня назад +4

    Success is not final, failure is not fatal : its the courage to continue that counts.

  • @hare_krishna8411
    @hare_krishna8411 2 дня назад +2

    bhaiya raadhe raadhe..❤❤

  • @divanshurawat8998
    @divanshurawat8998 День назад +1

    Happy Birthday Bhayia🥳

  • @abhisheksingh-rz8nj
    @abhisheksingh-rz8nj 2 дня назад +1

    Happy Birthday Sir

  • @harshugamer7776
    @harshugamer7776 2 дня назад +2

    Happy Birthday 🥳

  • @thefinalfit
    @thefinalfit 2 дня назад +1

    Happy Birthday MIK 🎉

  • @HeetVichhivora
    @HeetVichhivora 2 дня назад +3

    Happiest birthday Mik bhai may God bless you with infinite success🎉🎉🎉🎉

  • @rishabraj7432
    @rishabraj7432 2 дня назад +1

    Happy BD guru

  • @shubham76
    @shubham76 2 дня назад +1

    Happy Birthday 🎉 sir

  • @arnabsarkar5245
    @arnabsarkar5245 2 дня назад +1

    Many many happy returns of the day bhaiya...

  • @unknown47896
    @unknown47896 2 дня назад +1

    Happy Birthday to the GOAT of DSA❤❤❤❤

  • @sumatheultimategirl7477
    @sumatheultimategirl7477 2 дня назад +1

    Happy Birthday mike🥳🥳🥳🥳💖💖

  • @storytv796
    @storytv796 2 дня назад +1

    Happy Birthday sir ji

  • @11csepratikshaargulewar71
    @11csepratikshaargulewar71 2 дня назад +1

    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

  • @godlovers5352
    @godlovers5352 2 дня назад +1

    Happy birthday sir ❤🎉

  • @FanIQQuiz
    @FanIQQuiz 2 дня назад +1

    Happy Birthday Guruji 🎂✨

  • @vishwashsoni610
    @vishwashsoni610 2 дня назад +2

    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 2 дня назад

      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.

  • @hellsterkun8764
    @hellsterkun8764 2 дня назад +4

    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.❤

  • @AbhishekKumar-hu2pz
    @AbhishekKumar-hu2pz 2 дня назад +1

    Happy Birthday bro
    god bless u

  • @bhuppidhamii
    @bhuppidhamii 2 дня назад +1

    Happy Birthday bhaiya ❤

  • @salmaniproductions1104
    @salmaniproductions1104 2 дня назад +1

    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.

  • @ayushmanbaghel7659
    @ayushmanbaghel7659 2 дня назад +1

    Happy Birthday GOAT for your subscribers ♥♥

  • @shaikhanif7268
    @shaikhanif7268 2 дня назад +1

    Happy Birthday bhaiya🎉

  • @HarmanSingh-nw6ix
    @HarmanSingh-nw6ix 2 дня назад +1

    wishing you a very very happy birthday bhaiya , may god help you achieve all your dreams as you help us achieving ours...♥♥♥

  • @ch0c0_1
    @ch0c0_1 2 дня назад +3

    Waah mik bhai .. aaj mera bhi birthday h ... Happy birthday to us both❤

  • @DevanshGupta-io7rl
    @DevanshGupta-io7rl 2 дня назад +1

    happy birthday bhaiya

  • @gauravmundhada1647
    @gauravmundhada1647 2 дня назад +1

    Happy birthday❤

  • @shreyabajaj4588
    @shreyabajaj4588 2 дня назад +1

    Happy Birthday Bhaiya ...

  • @saminkhan125
    @saminkhan125 2 дня назад +1

    Wising you a very happy birthday MIK

  • @shubhamsharma4353
    @shubhamsharma4353 2 дня назад +1

    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)

  • @yashraj5898
    @yashraj5898 2 дня назад +1

    happy birthday sir, and please always include the brute force solution as it enhances the thinking ability of ours.

  • @kakshat22
    @kakshat22 2 дня назад +1

    Happpy birthday MIK bro ❤🎉

  • @joydeep-halder
    @joydeep-halder 2 дня назад +1

    Happy Birthday bhaiya 🎂🎂🎉🎉

  • @harshitkaundal6373
    @harshitkaundal6373 17 часов назад +1

    Happy Birthday Bro, Sorry late hogya

  • @TheRUSHIZ
    @TheRUSHIZ День назад +1

    Happy Birthday Bhaiya!! can you please make a playlist of prefix sum

  • @SRoy2700
    @SRoy2700 2 дня назад +1

    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

  • @UTKARSHSHUKLAIIITT
    @UTKARSHSHUKLAIIITT 2 дня назад +1

    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

  • @joydeep-halder
    @joydeep-halder 2 дня назад +6

    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]

  • @100solarmass
    @100solarmass 2 дня назад +1

    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;
    }
    }

  • @sauravchandra10
    @sauravchandra10 2 дня назад +1

    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! ❤

  • @universalcosmologist3675
    @universalcosmologist3675 День назад +1

    bro pls make video on line sweep algorithm plssss i request 🙏🙏🙏🙏🙏🙏🙏🙏

  • @Amanbiragi17
    @Amanbiragi17 2 дня назад +1

    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

  • @DevanshGupta-io7rl
    @DevanshGupta-io7rl 2 дня назад +1

    int waysToSplitArray(vector& nums) {
    int n=nums.size(),cnt=0;
    vectorprefsum(n);
    prefsum[0]=nums[0];
    for(int i=1;i

  • @gui-codes
    @gui-codes 2 дня назад +2

    Sir aaj Birthday me to rest karlo 😅.
    Happy Birthday Legend ❤

  • @imPriyansh77
    @imPriyansh77 День назад +1

    Prefix Sum - Easy Problem

  • @ishikacasley2786
    @ishikacasley2786 2 дня назад +1

    //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;
    }
    };

  • @Dnsndy
    @Dnsndy 2 дня назад +1

    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;
    }
    };

  • @sayyedrehan-y1j
    @sayyedrehan-y1j День назад +1

    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.

  • @jeehub041
    @jeehub041 2 дня назад +1

    Bhaiya kya isse one pass me bhi kia jaa sakta ha like without calculating total sum initially?

  • @AnkushKaudi
    @AnkushKaudi 2 дня назад +1

    Saw today's problem statement, figured out the optimal solution in

  • @DevanshGupta-io7rl
    @DevanshGupta-io7rl 2 дня назад +1

    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

  • @prajwalshaw9217
    @prajwalshaw9217 День назад

    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.

  • @YogeshShinde-l4b
    @YogeshShinde-l4b День назад +2

    Vote for Mike DSA sheet

  • @B-Billy
    @B-Billy 2 дня назад

    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;
    }
    }

  • @arjunkumaryadav8102
    @arjunkumaryadav8102 День назад +1

    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

  • @AyushKumar-e5j1v
    @AyushKumar-e5j1v День назад +1

    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 🙏🙏🙏

  • @algosafari
    @algosafari 2 дня назад +1

    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

  • @Vibhanshushrivastava
    @Vibhanshushrivastava 17 часов назад +1

    sir please leetcode 3409 , its a biweekly 147 contest question, kch smjh ni pdrha kya hua isme , pretty hard question i would say

  • @akashsahoo2421
    @akashsahoo2421 День назад

    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.

  • @gauravparasar4571
    @gauravparasar4571 2 дня назад

    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

  • @algosafari
    @algosafari 2 дня назад

    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

  • @girlwithwings4903
    @girlwithwings4903 2 дня назад

    silly doubt - abhi bhi to loop do baar cahl raha hai to TC n2 kyu nhi hai 😐

  • @Rahulkumar-bn4tk
    @Rahulkumar-bn4tk 2 дня назад

    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 2 дня назад +1

      Bro koi problem nahi bass time invest karte rahoo in learning, kuch din baad ABCD jaise hoo jae gaa

    • @Rahulkumar-bn4tk
      @Rahulkumar-bn4tk День назад

      @@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 16 часов назад

      @@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 2 дня назад +2

    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 2 дня назад +1

    Did by my own optimally🤎