Smallest Positive Integer that can not be represented as Sum |Maths-10| Placement Preparation Series

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

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

  • @yashkhatwani3198
    @yashkhatwani3198 2 года назад +4

    In simple words
    # if the current number is greater than ans , than ans can never be formed simply return it
    # else we can form answer till ans+ arr[i] as everything between it can be formed

    • @BroCoders
      @BroCoders  2 года назад +1

      This is the focus with which one should watch video....great!!

  • @ArnabJhaYT
    @ArnabJhaYT 2 года назад +1

    long long smallestpositive(vector arr, int n)
    {
    sort(arr.begin(), arr.end());
    long long curr = arr[0];
    if(arr[0] != 1)
    return 1;
    for(int i = 1; i curr+1)
    return curr+1;
    curr += arr[i];
    }
    return curr+1;
    }
    TC - NLOGN
    SC - 1

  • @arghya_0802
    @arghya_0802 2 года назад +1

    The video is exceptionally good!! Itna achhe se question samjhaye Karan sir ne!! Intuition bhi samajh aa gaya aur code to cake-walk tha.
    Summary:
    1. Sort the array so that we move in sequence
    2. Iterate from i = 0 till N
    3. ans = 1. If we find any number in array which is greater than ans, we return it
    4. Else we add the number to the ans
    5. At the end, we return ans if we traverse the complete array.
    Intuition:
    If nums[i] ans, we cannot form it using the the elements we have encountered till now, so smallest positive is our ans only

  • @yourbestie4138
    @yourbestie4138 2 года назад +2

    Wow , such a nice explanation

  • @naman120
    @naman120 2 года назад +1

    Very Good Solution Approach

  • @Gaurav_kumar_mgk
    @Gaurav_kumar_mgk 2 года назад +1

    great explaination

    • @BroCoders
      @BroCoders  2 года назад

      Thanks Gaurav!!
      Do share among your friends!!

  • @krishnavar7219
    @krishnavar7219 Год назад

    how you said time complexity of it...i got understand

  • @uknowme48
    @uknowme48 2 года назад +1

    day 3 problem 1

    • @BroCoders
      @BroCoders  2 года назад

      Hope you reach to very end!!

  • @RAHULCHOUDHARY-ij2pt
    @RAHULCHOUDHARY-ij2pt 3 года назад +2

    thanks bro

  • @ArnabJhaYT
    @ArnabJhaYT 3 года назад +1

    great intuition. Thanks, brother.

  • @ashvinkumhar5819
    @ashvinkumhar5819 2 года назад +1

    respect++