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

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ก.ค. 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

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

  • @youtubeofomkar
    @youtubeofomkar 6 หลายเดือนก่อน +18

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

    • @GeetainSaar
      @GeetainSaar 28 วันที่ผ่านมา +1

      Thumbnail

    • @Homelander_30
      @Homelander_30 10 วันที่ผ่านมา +1

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

  • @yashrajput8566
    @yashrajput8566 2 หลายเดือนก่อน +4

    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 ปีที่แล้ว +7

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

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

    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  29 วันที่ผ่านมา

      It's my pleasure

  • @atmurisaimouli4697
    @atmurisaimouli4697 5 หลายเดือนก่อน +2

    Mind Blowing Explaination , Very Clear and Consice

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

    You are a gem!

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

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

  • @lymmontijo87
    @lymmontijo87 9 หลายเดือนก่อน

    Thank you so much, this explanation was super helpful.

  • @akankshajain3997
    @akankshajain3997 9 หลายเดือนก่อน +1

    such a clean explanation with visuals, thank you!

    • @nikoo28
      @nikoo28  8 หลายเดือนก่อน

      so happy you like them

  • @hoang640
    @hoang640 9 หลายเดือนก่อน

    Very clear explaination
    Thank you so much

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

    Really Good content... Best video lecture on TH-cam. Keep doing good work

  • @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

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

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

  • @bhawnachauhan4375
    @bhawnachauhan4375 5 หลายเดือนก่อน +1

    You explained so well😊

  • @vpvpsilly2927
    @vpvpsilly2927 11 หลายเดือนก่อน +1

    great explanation....thank you sir

  • @sourabhtiwari5137
    @sourabhtiwari5137 5 หลายเดือนก่อน +2

    better than more phd holder, great explanation

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

    great video and very well explained 😃

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

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

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

    Thanks man. Good coding.

  • @ashok2089
    @ashok2089 10 วันที่ผ่านมา

    Best explanation..thanks!

  • @rohitrajsingh4638
    @rohitrajsingh4638 6 หลายเดือนก่อน

    best explanation that i found

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

    Thanks for the video

  • @niom_002
    @niom_002 5 หลายเดือนก่อน

    Great explanation ❤

  • @user-gw2dz6il1n
    @user-gw2dz6il1n หลายเดือนก่อน +1

    great understanding

  • @mohammadfahad6076
    @mohammadfahad6076 9 หลายเดือนก่อน

    great explanation👍

  • @aniketrawat3224
    @aniketrawat3224 10 หลายเดือนก่อน

    Thanks, it was really helpfull...

  • @chandanaarvapally
    @chandanaarvapally วันที่ผ่านมา

    You are toooo good! Thanks a lot sir

  • @MoralStories292
    @MoralStories292 2 หลายเดือนก่อน

    the best explanation❤❤❤❤

  • @-IT-ARGHYASINGHA
    @-IT-ARGHYASINGHA 4 หลายเดือนก่อน

    thank you very much sir nicely explained

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

    Thankyou sir.

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

    well explained

  • @enriquegrageda
    @enriquegrageda 5 หลายเดือนก่อน +1

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

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

    very underrated channel

  • @xzcgvxzcvxzcvxcv
    @xzcgvxzcvxzcvxcv 5 หลายเดือนก่อน +1

    It's more better explanation than neetcode) thx

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

    Bhaiya tussi GREAT ho!!!🎉

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

      you are great too :D

  • @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

  • @kidoo1567
    @kidoo1567 10 หลายเดือนก่อน

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

    • @nikoo28
      @nikoo28  9 หลายเดือนก่อน

      haha...you mean rob?

  • @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  4 หลายเดือนก่อน

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

  • @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  5 หลายเดือนก่อน

      Thank you, I will

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

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