RANDOM PICK WITH BLACKLIST (Leetcode) - Code & Whiteboard

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

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

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

    thanks!
    very cool and easy explanation.
    // didn't even watched the whole video, jumped straight to IDE at ~9:40 and implemented it based your whiteboard doc and wrote code+test that worked more or less (after leetcode catched a few bugs)

  • @mrboyban
    @mrboyban 2 ปีที่แล้ว

    Babybear must be the most underrated channel on youtube. What what precious explanation

    • @babybear-hq9yd
      @babybear-hq9yd  2 ปีที่แล้ว

      hahah appreciated buddy! "precious" is my new favourite adjective

  • @moorchini
    @moorchini 3 ปีที่แล้ว

    Every morning with Aleksandar! Cheers bro!

  • @xiaoheluo8380
    @xiaoheluo8380 3 ปีที่แล้ว

    Thanks for the clear and clever solution!

  • @anuraggorkar2299
    @anuraggorkar2299 3 ปีที่แล้ว

    Nice Explaination! New Sub ;)

  • @vsmunagala
    @vsmunagala 3 ปีที่แล้ว

    Thank You . Very nice explanation !!!

  • @WhisperingWalnuts
    @WhisperingWalnuts 2 ปีที่แล้ว

    first, Thanks for making this video, keep it up! I actually watched only your algo part and I am like I get it and started coding on my own. it turns out that I used array instead of set for tempWL and used my own index to keep track of index while creating blacklist->whitelist map. it turns out my submission timed out. So, do you know why we need to use set here and how it speeds up the time complexity that it does not time out when we use set.

    • @babybear-hq9yd
      @babybear-hq9yd  2 ปีที่แล้ว +1

      We can search through sets in O(1) time, but need O(n) time to search through an array. That’s the big benefit of sets :)

    • @WhisperingWalnuts
      @WhisperingWalnuts 2 ปีที่แล้ว

      @@babybear-hq9yd you are absolutely correct! How can I miss this ... "tempwl = [ i for i in range(n - lenB, n) if i not in blacklist ]". I made my tempwl from blacklist which is a silly mistake cause blacklist is an input array, and its going to cost o(n) for each lookup for "if i not in blacklist".. Thanks a lot!

  • @alphabetsoup4269
    @alphabetsoup4269 3 ปีที่แล้ว

    nice video

  • @jain007neeraj
    @jain007neeraj 3 ปีที่แล้ว

    Awesome....