Best Time To Buy & Sell Stock 1 (LeetCode 121) | Full solution with visuals and animation

Поделиться
HTML-код
  • Опубликовано: 10 июл 2024
  • Stock Market is a wonderful opportunity to make some money but surely, you need to time things correctly. In the given problem we have defined prices and our aim is to maximize the profit. Watch the video to understand with animations and visuals how we can achieve a maximum profit in just one iteration.
    Actual problem on LeetCode: leetcode.com/problems/best-ti...
    Chapters:
    00:00 - Intro
    00:56 - Problem Statement and Description
    03:24 - Brute Force Solution is not optimal
    05:47 - Working step by step
    11:38 - Dry-run of Code
    13:31 - Final Thoughts
    📚 Links to topics I talk about in the video:
    LeetCode Problems: • Leetcode Solutions
    Other easy difficulty problems: • Easy Problems
    Dynamic Programming: • Dynamic Programming ea...
    Greedy Algorithms: • Greedy Algorithms with...
    Kadane’s Algorithm: • Maximum Sub-Array Sum ...
    📘 A text based explanation is available at: studyalgorithms.com
    Code on Github: github.com/nikoo28/java-solut...
    Test-cases on Github: github.com/nikoo28/java-solut...
    📖 Reference Books:
    Starting Learn to Code: amzn.to/36pU0JO
    Favorite book to understand algorithms: amzn.to/39w3YLS
    Favorite book for data structures: amzn.to/3oAVBTk
    Get started for interview preparation: amzn.to/39ysbkJ
    🔗 To see more videos like this, you can show your support on: www.buymeacoffee.com/studyalg...
    🎥 My Recording Gear:
    Recording Light: amzn.to/3pAqh8O
    Microphone: amzn.to/2MCX7qU
    Recording Camera: amzn.to/3alg9Ky
    Tablet to sketch and draw: amzn.to/3pM6Bi4
    Surface Pen: amzn.to/3pv6tTs
    Laptop to edit videos: amzn.to/2LYpMqn
    💻 Get Social 💻
    Follow on Facebook at: / studyalgos
    Follow on Twitter at: / studyalgorithms
    Follow on Tumblr at: / studyalgos
    Subscribe to RSS feeds: studyalgorithms.com/feed/
    Join fan mail: eepurl.com/g9Dadv
    #leetcode #programming #interview

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

  • @youtubeofomkar
    @youtubeofomkar 6 месяцев назад +16

    Why are his lectures not having enough views? They are so good.

    • @GeetainSaar
      @GeetainSaar 22 дня назад +1

      Thumbnail

    • @Homelander_30
      @Homelander_30 4 дня назад

      They love only clickbait and trends. He is treasure, hope he start DSA course, I will buy at any cost.

  • @yashrajput8566
    @yashrajput8566 2 месяца назад +3

    one of the best yet simple solution i have seen so far.

  • @sreeharsharaveendra289
    @sreeharsharaveendra289 6 месяцев назад +8

    Your clear explanation is so good. Clearly this video deserves more views, bless you!

    • @nikoo28
      @nikoo28  6 месяцев назад +1

      thanks for your appreciation and motivation :)

  • @movocode
    @movocode 3 месяца назад +5

    How come your views are so low....its literally the best explanation i am getting on youtube ....already watched few of your videos...always thinking why you are so underrated.

  • @zmonkey111
    @zmonkey111 Год назад +6

    So happen I randomly found you. Thank you for the content. You are definitely helping me understand the coding mindset.

  • @manansarraf73
    @manansarraf73 23 дня назад

    bhaiya whenever i got stuck in DSA you always saved me. i have watched number of videos of yours on DSA and always got the best solution always

    • @nikoo28
      @nikoo28  23 дня назад

      It's my pleasure

  • @MythBuster28_10
    @MythBuster28_10 4 месяца назад

    This explanation deserves more views and sharing with friends and colleagues. Simply brilliant

  • @atmurisaimouli4697
    @atmurisaimouli4697 5 месяцев назад +2

    Mind Blowing Explaination , Very Clear and Consice

  • @lymmontijo87
    @lymmontijo87 9 месяцев назад

    Thank you so much, this explanation was super helpful.

  • @riyarai9226
    @riyarai9226 Месяц назад

    Thank you so much sir, this explanation was super helpful.

  • @akankshajain3997
    @akankshajain3997 8 месяцев назад +1

    such a clean explanation with visuals, thank you!

    • @nikoo28
      @nikoo28  8 месяцев назад

      so happy you like them

  • @hoang640
    @hoang640 8 месяцев назад

    Very clear explaination
    Thank you so much

  • @susmitapatil4847
    @susmitapatil4847 4 месяца назад

    Really Good content... Best video lecture on RUclips. Keep doing good work

  • @harshitagoswami989
    @harshitagoswami989 Год назад +3

    You are a gem!

  • @anuradhae9146
    @anuradhae9146 Год назад +1

    really appreciate your effort to explain and how to reach to solution step by steps. It is great help. keep it up!! thanks lot

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

      you are very welcome!!

  • @tayyabsami258
    @tayyabsami258 4 месяца назад

    Brother your explanation is love

  • @ashok2089
    @ashok2089 4 дня назад

    Best explanation..thanks!

  • @sourabhtiwari5137
    @sourabhtiwari5137 5 месяцев назад +2

    better than more phd holder, great explanation

  • @kirthananambiar8873
    @kirthananambiar8873 Год назад +1

    Thank you for your great explanation..it will be great if you solve hackerank array manipulation problem

  • @bhawnachauhan4375
    @bhawnachauhan4375 5 месяцев назад +1

    You explained so well😊

  • @iftekharanam8980
    @iftekharanam8980 4 месяца назад

    Thanks man. Good coding.

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

    great video and very well explained 😃

  • @vpvpsilly2927
    @vpvpsilly2927 11 месяцев назад +1

    great explanation....thank you sir

  • @rohitrajsingh4638
    @rohitrajsingh4638 5 месяцев назад

    best explanation that i found

  • @-IT-ARGHYASINGHA
    @-IT-ARGHYASINGHA 4 месяца назад

    thank you very much sir nicely explained

  • @aniketrawat3224
    @aniketrawat3224 10 месяцев назад

    Thanks, it was really helpfull...

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

    Thanks for the video

  • @MoralStories292
    @MoralStories292 2 месяца назад

    the best explanation❤❤❤❤

  • @yaswanthreddy2623
    @yaswanthreddy2623 4 месяца назад

    Thankyou sir.

  • @user-gw2dz6il1n
    @user-gw2dz6il1n Месяц назад +1

    great understanding

  • @niom_002
    @niom_002 5 месяцев назад

    Great explanation ❤

  • @enriquegrageda
    @enriquegrageda 5 месяцев назад +1

    You should be a tutor or teacher,
    thanks for uploading :D

  • @mohammadfahad6076
    @mohammadfahad6076 9 месяцев назад

    great explanation👍

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

    well explained

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

    Bhaiya tussi GREAT ho!!!🎉

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

      you are great too :D

  • @xzcgvxzcvxzcvxcv
    @xzcgvxzcvxzcvxcv 5 месяцев назад +1

    It's more better explanation than neetcode) thx

  • @ajayupadhyay4964
    @ajayupadhyay4964 Год назад +1

    very underrated channel

  • @subee128
    @subee128 6 месяцев назад

    Thanks

    • @nikoo28
      @nikoo28  6 месяцев назад

      Welcome

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

    i love your english

  • @raah1634
    @raah1634 4 месяца назад

  • @manishasharma434
    @manishasharma434 Год назад +1

    Pls do cover all the parts of buy and sell problem if possible

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

      yep...I do have that on my mind 😄

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

    👍

  • @TrungNguyen-eo7qz
    @TrungNguyen-eo7qz 4 месяца назад

    How to find and return the indices of best day to buy and best day to sell with max profit?

    • @nikoo28
      @nikoo28  4 месяца назад

      that is another problem...and will cover it at a later point in time

  • @akjha627
    @akjha627 5 месяцев назад

    I wrote the code myself and I am confused with the test cases...[3,2,6,5,0,3] expects the output to be 4 whereas [2,1,2,1,0,1,2] expects output to be 2. So in first testcase, the 0 price is not valid whereas in the 2nd, 0 buy price is valid ??

    • @nikoo28
      @nikoo28  3 месяца назад

      try debugging and you will be able to follow along the step you are missing

  • @kidoo1567
    @kidoo1567 9 месяцев назад

    U are looking like that guy who host the show "the mad" in pogo❤

    • @nikoo28
      @nikoo28  8 месяцев назад

      haha...you mean rob?

  • @asifkhanak7792
    @asifkhanak7792 6 месяцев назад

    what is the name of this algorithm?

    • @nikoo28
      @nikoo28  6 месяцев назад

      Kadane's algorithm

  • @adityathakur9714
    @adityathakur9714 6 месяцев назад

    Sir please write code also at the last by yourself

    • @nikoo28
      @nikoo28  6 месяцев назад

      I want to focus on the problem solving part rather than the code part. Once the algorithm is clear to you...writing the code in any language isn't hard at all. Every good company you interview for...they will only be interested to judge if you are able to think logically.
      Plus, I also provide a production level code at the end with a dry run, full code and test cases on Github as well.
      So my question to you is, did you face any problems while understanding how to solve?

    • @adityathakur9714
      @adityathakur9714 6 месяцев назад

      @@nikoo28 No bhaiyaa the thing is I just started coding I understand the logic very well with your explanation but I'm not able to write in a limited time and bhaiya you explain so well that I understand the logic easily.

    • @nikoo28
      @nikoo28  6 месяцев назад

      If you have just started your coding journey…all the more reason to try and write the code yourself…follow the logic and debug along the way.
      Pause and take your time. No rush to just complete the number of problems.

    • @adityathakur9714
      @adityathakur9714 6 месяцев назад

      @@nikoo28 okk bhaiya i will give my best

  • @pavankumarpadamati8606
    @pavankumarpadamati8606 5 месяцев назад

    nice explanation ...keep it bro🤩

    • @nikoo28
      @nikoo28  4 месяца назад

      Thank you, I will

  • @riyarai9226
    @riyarai9226 Месяц назад

    Thank you so much sir, this explanation was super helpful.