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

Sdílet
Vložit
  • čas přidán 28. 07. 2024
  • In this video, I'll talk about how to solve the problem Leetcode 1802. Maximum Value at a Given Index in a Bounded Array
    Problem Link: leetcode.com/problems/maximum...
    Code & Notes: drive.google.com/file/d/1idh2...
    Maximum Value at a Given Index in a Bounded Array || Math || Binary Search || Leetcode 1802
    Let's Connect:
    📝Linkedin: / aryan-mittal-0077
    📸 Instagram: / aryan_mittal_007
    📱Telegram : t.me/aryan_mittal_group
    🤖 Github: github.com/aryan-0077
    🛍️ Products I use in Videos: (✨ Marked for Mostly requested Products)
    Main Camera (Canon 200D ii): amzn.to/41cfS5h
    Vlog Camera (iphone 13): amzn.to/42aOJRh
    Tripod for Lectures: amzn.to/3HMoloF
    Tripod for Vlogs: amzn.to/44wGL6L
    ✨Mic: amzn.to/41bj8gU
    Shadow Multi Colour Light: amzn.to/41bmIrq
    Main Light: amzn.to/3LF6BNb
    Tripod for Lights: amzn.to/3LFcQAt
    Softbox for Lights: amzn.to/42mHqWE
    ✨My Pen Tablet for Notes: amzn.to/44A61ZJ
    ✨New Tablet for Notes: amzn.to/44BjTDa
    Tablet Stand: amzn.to/3NMFIJR
    Power Bank: amzn.to/421yHsZ
    ✨USB Hub: amzn.to/3p8NGTf
    ✨HardDisk to store Lectures: amzn.to/3HKafEs
    ✨My Laptop: amzn.to/44w12ct
    ✨My Monitor: amzn.to/3LCG6YL
    My UPS: amzn.to/3Lydy2y
    My UPS old: amzn.to/3LXT0C3
    ✨My Mouse: amzn.to/3LYmJdY
    ✨My Keyboard: amzn.to/3NJs4ah
    Resources you can try:
    Learn Coding: • Complete RoadMap for C...
    🎥Channel Playlists
    🎥 Baap Graph Series - by Aryan: • Baap Graph Series - by...
    🎥Dynamic Programming: • Complete Dynamic Progr...
    🎥Bit Manipulation: • Complete BIT MANIPULAT...
    🎥Mathematics for DSA: • Complete Mathematics f...
    🎥Leetcode Top Interview Questions: • FAANG & Leetcode Inter...
    🎥Codeforces Problem B Ladder: • Complete PROBLEM B LAD...
    🎥Codeforces Problem C Ladder: • Codeforces PROBLEM C L...
    🎥Codeforces Problem D Ladder: • Complete PROBLEM D LAD...
    🎥 Top 150 Interview Questions: • Top 150 Interview Ques...
    🎥 Complete Array Problem Playlist: • Complete Array Intuit...
    🎥 Complete Binary Search Problem Playlist: • Complete Binary Search...
    🎥 Complete Stack Playlist: • Complete Stack & Queue...
    🎥 Complete Graph Problem Playlist: • Complete Graph Intuiti...
    🎥 Complete TREE Playlist: • Complete TREE Intuitio...
    🎥 Complete DP Problem Solving: • Complete DP Intuition ...
    🎥 Complete Linked List: • Complete Linked List I...
    🎥 Complete Greedy Problem Playlist: • Complete Greedy Intui...
    🎥 Complete Divide & Conquer Algorithm Playlist: • Complete Divide & Conq...
    🎥 Complete Trie Playlist: • Complete Trie Intuitio...
    🎥 Complete Mathematics & Number Theory Problems: • Complete Mathematics &...
    About Channel:
    We teach about how you can grow in life & educate about programming in Fun & Intuitional way.
    About Me:
    I am Aryan Mittal - a Software Engineer, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
    ✨ Timelines✨
    0:00 - Problem Explanation
    3:09 - Intuition & Logic
    15:30 - Code Explanation
    ✨ Hashtags ✨
    #programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Komentáře • 52

  • @ARYANMITTAL
    @ARYANMITTAL  Před rokem +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 Před rokem

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

  • @vaibhav8257
    @vaibhav8257 Před rokem +1

    Clearly Understood the intuition thanks!

  • @ManojKumarManuSai
    @ManojKumarManuSai Před rokem +1

    Great explanation. Thanks Aryan.

  • @oqant0424
    @oqant0424 Před rokem +1

    Thanks for the excellent explanation

  • @AmarjeetKumar-to9ub
    @AmarjeetKumar-to9ub Před rokem +1

    Thank You :)

  • @dhanashreegodase4445
    @dhanashreegodase4445 Před rokem

    suchh a great explanation

  • @user-pz2ng5qq6y
    @user-pz2ng5qq6y Před rokem

    Best explanation so far!

  • @anmolraj4995
    @anmolraj4995 Před rokem +3

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

  • @kunjdabhi943
    @kunjdabhi943 Před rokem

    Great Explanation!!!

  • @gouravkumarshaw417
    @gouravkumarshaw417 Před rokem

    Nice explanation thanks!!

  • @StellasAdi18
    @StellasAdi18 Před rokem +1

    Best explanation!

  • @rupdeepthey
    @rupdeepthey Před rokem

    Thanks for the help bro.🙏

  • @vedbhanushali608
    @vedbhanushali608 Před rokem

    nice explanation thanks .

  • @rmaravind940
    @rmaravind940 Před rokem

    excellent explanation made my day

  • @iamnoob7593
    @iamnoob7593 Před 2 měsíci

    Man this is brilliant

  • @niteshshandilya4226
    @niteshshandilya4226 Před rokem

    gr8 bhai

  • @tonyli1957
    @tonyli1957 Před 11 měsíci +1

    you are f***g smart

  • @ananttater1146
    @ananttater1146 Před rokem

    Thanks bro...

  • @piyushnautiyal5112
    @piyushnautiyal5112 Před rokem +1

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

  • @abhishekvishwakarma9045

    Best explanation 🔥 Keep going aryan

  • @suneedhiladdha
    @suneedhiladdha Před rokem

    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?

  • @satwiktatikonda764
    @satwiktatikonda764 Před 6 měsíci

    what are the earlier 2 concepts

  • @sakshamgupta3921
    @sakshamgupta3921 Před rokem

    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?

  • @salmankhader1258
    @salmankhader1258 Před rokem

    plz upload the leetcode contest solutions as well

  • @poojithkumar2283
    @poojithkumar2283 Před rokem

    if the array contains negetive numbers how to find the sum

  • @sunwoodad
    @sunwoodad Před 11 měsíci

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

  • @sathishkumar-dc9ce
    @sathishkumar-dc9ce Před rokem +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 Před rokem +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

  • @SD-vk3ko
    @SD-vk3ko Před rokem +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 Před rokem +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_ Před rokem +1

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

    • @ialgorithms
      @ialgorithms Před rokem

      @@_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])

  • @udaytewary3809
    @udaytewary3809 Před rokem +1

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

  • @sambitbasu6261
    @sambitbasu6261 Před rokem +3

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

    • @kushagraahire1871
      @kushagraahire1871 Před rokem

      0 based indexing

    • @anzilmufti2682
      @anzilmufti2682 Před rokem

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

    • @kushagraahire1871
      @kushagraahire1871 Před rokem

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

  • @sravanigundepalli3513

    can someone please explain how to learn from given constraints

    • @password47403
      @password47403 Před rokem +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 Před rokem

      @@password47403 Okayy thank you :)

  • @himanshumaurya479
    @himanshumaurya479 Před rokem

    your explaination is good but try to explain slowly.

  • @riskyone9600
    @riskyone9600 Před rokem +1

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

  • @dimabirenbaum9200
    @dimabirenbaum9200 Před rokem

    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.

  • @anandharsh1773
    @anandharsh1773 Před rokem +3

    bhaii thoda over acting kam kiya kar.

  • @raginibhayana8305
    @raginibhayana8305 Před rokem

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

  • @vedantupadhyay42
    @vedantupadhyay42 Před rokem +1

    Feels like should drop programming..

  • @thedarkknight1865
    @thedarkknight1865 Před rokem +7

    butt butt butt band kar bhai

  • @snigdhobhattacharya4697

    Thanks for the excellent explanation