Maximum Value at a Given Index in a Bounded Array || Math || Binary Search || Leetcode 1802

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ก.ย. 2024

ความคิดเห็น • 52

  • @ARYANMITTAL
    @ARYANMITTAL  ปีที่แล้ว +8

    Code & Notes: drive.google.com/file/d/1idh2GHvawPRvYUqvV4rGWkX_rToLEav6/view?usp=sharing
    Kon kon logic soch liya tha Binary Search and AP ka ?? 💪

    • @roshanraturi6450
      @roshanraturi6450 ปีที่แล้ว

      ME BUT IMPLEMENTATION NHI HO PARHA THA THIK SE ..THANK YOU FOR YOUR INTUTION && LOGIC

  • @vaibhav8257
    @vaibhav8257 ปีที่แล้ว +1

    Clearly Understood the intuition thanks!

  • @oqant0424
    @oqant0424 ปีที่แล้ว +1

    Thanks for the excellent explanation

  • @ManojKumarManuSai
    @ManojKumarManuSai ปีที่แล้ว +1

    Great explanation. Thanks Aryan.

  • @niteshshandilya4226
    @niteshshandilya4226 ปีที่แล้ว

    gr8 bhai

  • @StellasAdi18
    @StellasAdi18 ปีที่แล้ว +1

    Best explanation!

  • @iamnoob7593
    @iamnoob7593 4 หลายเดือนก่อน

    Man this is brilliant

  • @tonyli1957
    @tonyli1957 ปีที่แล้ว +1

    you are f***g smart

  • @dhanashreegodase4445
    @dhanashreegodase4445 ปีที่แล้ว

    suchh a great explanation

  • @rmaravind940
    @rmaravind940 ปีที่แล้ว

    excellent explanation made my day

  • @AmarjeetKumar-to9ub
    @AmarjeetKumar-to9ub ปีที่แล้ว +1

    Thank You :)

  • @vedbhanushali608
    @vedbhanushali608 ปีที่แล้ว

    nice explanation thanks .

  • @YuktiSethi-c6f
    @YuktiSethi-c6f ปีที่แล้ว

    Best explanation so far!

  • @SD-vk3ko
    @SD-vk3ko ปีที่แล้ว +4

    Hey Aryan, I regularly watch your videos... Thanks for all the effort you put in.
    I have a question, if you don't mind answering, is, How much the solution will differ, if the question would allow "0" in array?

    • @ialgorithms
      @ialgorithms ปีที่แล้ว +1

      Thanks for bringing this up, I was on the same page.
      If 0 is allowed (or the range was 0 < i < n), then nums[index] will be maxSum. Values to the left of nums[index] will be 0 and right will be 0. Which satisfies other conditions.

    • @_hrishav_
      @_hrishav_ ปีที่แล้ว +1

      @@ialgorithms If nums[index]==maxSum & all other indices have 0, then how will "abs(nums[i] - nums[i+1])

    • @ialgorithms
      @ialgorithms ปีที่แล้ว

      @@_hrishav_ The question asked in this question (First comment) has no correlation with the actual problem statement. It's a though process which occurred when solving the problem for the first time presuming that "0" was allowed in the array list. So, you could ignore this comment as it has nothing to do with the actual question.
      To your question, abs(nums[i] - nums[i+1])

  • @salmankhader1258
    @salmankhader1258 ปีที่แล้ว

    plz upload the leetcode contest solutions as well

  • @piyush5112
    @piyush5112 ปีที่แล้ว +1

    Its giving runtime error signed integer overflow even after using long long int what to do brother

  • @sambitbasu6261
    @sambitbasu6261 ปีที่แล้ว +3

    Maybe this is a silly question, but why are we taking el =mid - 1?

    • @kushagraahire1871
      @kushagraahire1871 ปีที่แล้ว

      0 based indexing

    • @anzilmufti2682
      @anzilmufti2682 ปีที่แล้ว

      @@kushagraahire1871 why are we even taking el=mid-1, i mean what's the logic behind it

    • @kushagraahire1871
      @kushagraahire1871 ปีที่แล้ว

      ​@@anzilmufti2682 Logically it is not compulsory to take mid -1 , we can take mid also the code should run

  • @gouravkumarshaw417
    @gouravkumarshaw417 ปีที่แล้ว

    Nice explanation thanks!!

  • @kunjdabhi943
    @kunjdabhi943 ปีที่แล้ว

    Great Explanation!!!

  • @ananttater1146
    @ananttater1146 ปีที่แล้ว

    Thanks bro...

  • @rupdeepthey
    @rupdeepthey ปีที่แล้ว

    Thanks for the help bro.🙏

  • @anmolraj4995
    @anmolraj4995 ปีที่แล้ว +3

    hey why are we taking ele as mid -1 not simply mid

  • @abhishekvishwakarma9045
    @abhishekvishwakarma9045 ปีที่แล้ว

    Best explanation 🔥 Keep going aryan

  • @sunwoodad
    @sunwoodad ปีที่แล้ว

    Thank you, you are the best. One question, inside of while loop, why el should be mid-1? It can't be mid?

  • @riskyone9600
    @riskyone9600 ปีที่แล้ว +1

    explanation - INT_MIN, but but but but but but but but but = LONG _MAX

  • @sathishkumar-dc9ce
    @sathishkumar-dc9ce ปีที่แล้ว +2

    Hi Aryan, should the leftpart and rightpart of the array (excluding index) always be array[index]-1. Cant it also be array[index]?. In simple words shoud ele=mid-1 or it can be mid also. Because I have seen results like [1,2,2,1] where index is 2. Can somebody explain this.

    • @arshgupta9038
      @arshgupta9038 ปีที่แล้ว +1

      it can be array[mid] as well. it can also be array[index]-1.In order to minimise the sum we do array[mid]-1.
      [1,2,2,1] could also be written as [1,2,1,1] .We try to minimise the sum , so we can get the max value at index which can pass the sum condition

  • @udaytewary3809
    @udaytewary3809 ปีที่แล้ว +1

    How at 7:26 array sum is equal to maxSum as array sum is 10 and array sum is 11

  • @satwiktatikonda764
    @satwiktatikonda764 7 หลายเดือนก่อน

    what are the earlier 2 concepts

  • @sakshamgupta3921
    @sakshamgupta3921 ปีที่แล้ว

    bhaiya just a small and silly doubt, how do you determine that we can't make the array just by knowing the limit is e^9?
    ik its related to time complexity but then till which range can we make the array or check for each number?

  • @suneedhiladdha
    @suneedhiladdha ปีที่แล้ว

    what if you have repeating numbers so say ur trying to make 18 with an array of 5 with index 2 maximized so you might have 34443. How do you apply n(n+1)/2 to it?

  • @dimabirenbaum9200
    @dimabirenbaum9200 ปีที่แล้ว

    I had to lower my sound to a minimum to keep listening to the explanation. I understand, you try to be different from others, but your main content is an explanation, not entertainment. The result of the video should be an understanding of the solution and key points learned, not the headache.

  • @himanshumaurya479
    @himanshumaurya479 ปีที่แล้ว

    your explaination is good but try to explain slowly.

  • @poojithkumar2283
    @poojithkumar2283 ปีที่แล้ว

    if the array contains negetive numbers how to find the sum

  • @anandharsh1773
    @anandharsh1773 ปีที่แล้ว +3

    bhaii thoda over acting kam kiya kar.

  • @vedantupadhyay42
    @vedantupadhyay42 ปีที่แล้ว +1

    Feels like should drop programming..

  • @sravanigundepalli3513
    @sravanigundepalli3513 ปีที่แล้ว

    can someone please explain how to learn from given constraints

    • @password47403
      @password47403 ปีที่แล้ว +1

      I also had a similar doubt as to how to analyze the constraints properly...check out this video of Aditya Verma where he shows how to analyse the constraints!
      All The Best!

    • @sravanigundepalli3513
      @sravanigundepalli3513 ปีที่แล้ว

      @@password47403 Okayy thank you :)

  • @raginibhayana8305
    @raginibhayana8305 ปีที่แล้ว

    can you please send the link of the two questions having the same concepts as of this question?

    • @ashishdhal4614
      @ashishdhal4614 ปีที่แล้ว +1

      Try solving search space problems in striver's a2z sheet

    • @raginibhayana8305
      @raginibhayana8305 ปีที่แล้ว +1

      @@ashishdhal4614 thank you

  • @thedarkknight1865
    @thedarkknight1865 ปีที่แล้ว +7

    butt butt butt band kar bhai

  • @snigdhobhattacharya4697
    @snigdhobhattacharya4697 ปีที่แล้ว

    Thanks for the excellent explanation