LetsCode
LetsCode
  • 698
  • 35 694

Video

Leetcode 1472. Design Browser History (stack and queue)
zhlédnutí 26Před 12 hodinami
1472. Design Browser History
2390. Removing Stars From a String (stack)
zhlédnutí 15Před 12 hodinami
2390. Removing Stars From a String
Leetcode 682. Baseball Game (stack)
zhlédnutí 32Před 12 hodinami
682. Baseball Game
Leetcode 844. Backspace String Compare (two pointers)
zhlédnutí 8Před 14 hodinami
844. Backspace String Compare
Leetcode 844. Backspace String Compare (stack)
zhlédnutí 2Před 16 hodinami
844. Backspace String Compare
Leetcode 1441. Build an Array With Stack Operations (2 pointers)
zhlédnutí 12Před 16 hodinami
1441. Build an Array With Stack Operations
Leetcode 850. Rectangle Area II (sweep line idea)
zhlédnutí 32Před dnem
850. Rectangle Area II
Leetcode 56. Merge Intervals (greedy and sweep line)
zhlédnutí 25Před 14 dny
Leetcode 56. Merge Intervals (greedy and sweep line)
Leetcode 1854. Maximum Population Year (difference array)
zhlédnutí 12Před 21 dnem
Leetcode 1854. Maximum Population Year (difference array)
Leetcode 1893. Check if All the Integers in a Range Are Covered (difference array)
zhlédnutí 19Před 21 dnem
Leetcode 1893. Check if All the Integers in a Range Are Covered (difference array)
Leetcode 2848. Points That Intersect With Cars (difference array)
zhlédnutí 10Před 21 dnem
Leetcode 2848. Points That Intersect With Cars (difference array)
Leetcode 1094. Car Pooling (difference array)
zhlédnutí 16Před 21 dnem
Leetcode 1094. Car Pooling (difference array)
Leetcode 3148. Maximum Difference Score in a Grid (2d prefix sum)
zhlédnutí 7Před 21 dnem
Leetcode 3148. Maximum Difference Score in a Grid (2d prefix sum)
Leetcode 1738. Find Kth Largest XOR Coordinate Value (2d prefix sum)
zhlédnutí 16Před 21 dnem
Leetcode 1738. Find Kth Largest XOR Coordinate Value (2d prefix sum)
Leetcode 1524. Number of Sub-arrays With Odd Sum (bfs)
zhlédnutí 8Před 21 dnem
Leetcode 1524. Number of Sub-arrays With Odd Sum (bfs)
Leetcode 930. Binary Subarrays With Sum (prefix + hash)
zhlédnutí 9Před 21 dnem
Leetcode 930. Binary Subarrays With Sum (prefix hash)
Leetcode 1744. Can You Eat Your Favorite Candy on Your Favorite Day? (prefix sum)
zhlédnutí 12Před 21 dnem
Leetcode 1744. Can You Eat Your Favorite Candy on Your Favorite Day? (prefix sum)
Leetcode 2438. Range Product Queries of Powers (prefix sum)
zhlédnutí 5Před 21 dnem
Leetcode 2438. Range Product Queries of Powers (prefix sum)
Leetcode 3152. Special Array II (prefix sum)
zhlédnutí 7Před 21 dnem
Leetcode 3152. Special Array II (prefix sum)
Leetcode 2389. Longest Subsequence With Limited Sum (prefix sum)
zhlédnutí 9Před 21 dnem
Leetcode 2389. Longest Subsequence With Limited Sum (prefix sum)
Leetcode 2613. Beautiful Pairs (computational geometry and divide and conquer)
zhlédnutí 5Před 21 dnem
Leetcode 2613. Beautiful Pairs (computational geometry and divide and conquer)
Leetcode 2342. Max Sum of a Pair With Equal Sum of Digits (Two sum)
zhlédnutí 7Před 21 dnem
Leetcode 2342. Max Sum of a Pair With Equal Sum of Digits (Two sum)
Leetcode 2748. Number of Beautiful Pairs (two sum)
zhlédnutí 6Před 21 dnem
Leetcode 2748. Number of Beautiful Pairs (two sum)
Leetcode 2815. Max Pair Sum in an Array (two sum)
zhlédnutí 6Před 21 dnem
Leetcode 2815. Max Pair Sum in an Array (two sum)
Leetcode 2741. Special Permutations (bit dp)
zhlédnutí 2Před 28 dny
Leetcode 2741. Special Permutations (bit dp)
Leetcode 526. Beautiful Arrangement (bit dp)
zhlédnutí 12Před 28 dny
Leetcode 526. Beautiful Arrangement (bit dp)
Leetcode 1201. Ugly Number III (binary search answer)
zhlédnutí 12Před 28 dny
Leetcode 1201. Ugly Number III (binary search answer)
Leetcode 878. Nth Magical Number (binary search answer)
zhlédnutí 11Před 28 dny
Leetcode 878. Nth Magical Number (binary search answer)
Leetcode 2371. Minimize Maximum Value in a Grid (greedy)
zhlédnutí 5Před měsícem
Leetcode 2371. Minimize Maximum Value in a Grid (greedy)

Komentáře

  • @PigCurious
    @PigCurious Před 9 dny

    Thanks for the video, helped me out. keep up the good work! 🌸

  • @ohiogozaimasu
    @ohiogozaimasu Před 13 dny

    I have a doubt why we cannot make prefix sum of size same as nums size, why we initialize prefix sum 0 at 0 index

    • @letscode1000
      @letscode1000 Před 12 dny

      It's also ok without zero padding, we can prepare a padding 0 for easy handle edge cases, like prefix sum from index 2 - index 0, if no zero padding, you need to have the edge cases check and add more lines of code. if it has no index 0 padding, you need the if check to check if it is zero.

  • @ohiogozaimasu
    @ohiogozaimasu Před 13 dny

    Thank you bro, this solution really helped me...

  • @yashwanthnadella537
    @yashwanthnadella537 Před 18 dny

    Nice explanation!

  • @nikenuke
    @nikenuke Před 20 dny

    thank you!

  • @sherzodaxadov5939
    @sherzodaxadov5939 Před 24 dny

    good idea bro thanks

  • @lnaffable
    @lnaffable Před měsícem

    thanks broo

  • @Badboy_2803
    @Badboy_2803 Před měsícem

    Nyc Explaination Bro

  • @sallaklamhayyen9876
    @sallaklamhayyen9876 Před měsícem

    good explanation = thank you so much❤❤❤ please keep doing this kind of videos , because are very helpful for us

    • @letscode1000
      @letscode1000 Před měsícem

      thanks, I'll continue to improve the content and quality of the video.

  • @elliekong712
    @elliekong712 Před měsícem

    Thanks a lot!!!!! <3

  • @khushibhansali5786
    @khushibhansali5786 Před měsícem

    code does work when hamsters =".HH.H.H.H.."

    • @letscode1000
      @letscode1000 Před měsícem

      tested, works class Solution: def minimumBuckets(self, hamsters: str) -> int: n = len(hamsters) i, res = 0, 0 while i < n: if hamsters[i] == 'H': if i + 1 < n and hamsters[i + 1] == '.': i += 2 res += 1 elif i - 1 >= 0 and hamsters[i - 1] == '.': res += 1 else: return -1 i += 1 return res

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

    promo sm

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

    Thank you so much for the video! It really helped me learn sliding window, such a smart way to solve it, the logic behind it is quite tricky though.

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

    Nice Explanation

  • @riddle-master-ruben
    @riddle-master-ruben Před 3 měsíci

    Great solution and easy to understand thanks for the whiteboard explanation.

  • @hardiklimbachiya9046
    @hardiklimbachiya9046 Před 3 měsíci

    So far. easiest explanation found on youtube ..Thanks !

  • @xBlackMambaWT
    @xBlackMambaWT Před 3 měsíci

    great solution and explanation!

  • @whatshouldbethename4522
    @whatshouldbethename4522 Před 3 měsíci

    Can we use vanilla dijkstra instead?

  • @sayeedchowdhury11
    @sayeedchowdhury11 Před 3 měsíci

    Thanks, good explanation

  • @user-eo2du7xk4z
    @user-eo2du7xk4z Před 4 měsíci

    it is not binary search solution((

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

      hmm, maybe recursive or quick power is a good name

  • @tarushiarora8628
    @tarushiarora8628 Před 4 měsíci

    Explained it in precise and concise manner ..amazing

  • @dhmkkk
    @dhmkkk Před 4 měsíci

    your channel is a goldmine got my weekends covered now🙏

    • @letscode1000
      @letscode1000 Před 4 měsíci

      Thanks, I’ll continued the improvement, practice makes perfect!

  • @Anurag-gi2li
    @Anurag-gi2li Před 4 měsíci

    Thanks

  • @letscode1000
    @letscode1000 Před 4 měsíci

    The time complexity is O(n^4), sorry for that I didn't solve it online, after carefully checking, it should be this: we have s1, s2 with cache, it's n^2, we have for loop, it's now n^3, but we also have s1 == s2, it's another O(n), so the time complexity is O(n^4), if you have any questions, please make a comment.

  • @rajan-u6b
    @rajan-u6b Před 4 měsíci

    awesome bro.....thankx

  • @letscode1000
    @letscode1000 Před 4 měsíci

    time is O(m + n)

  • @letscode1000
    @letscode1000 Před 4 měsíci

    Time is O(n^2), there is for loop inside.

  • @vinayakbajpeyi931
    @vinayakbajpeyi931 Před 4 měsíci

    Cool video, thanks!

  • @szain98
    @szain98 Před 5 měsíci

    I think they have added new test cases to this problem, this solution gives TLE now. But my intuition is that you can actually abstract the inner for-loop into its own method (example: def parseSubstring(...){}. If the for-loop in this new method is somehow transformed into a recursive call, then you can add @cache decorator above the new parseSubstring(...) method signature to memoize the results and prevent TLE. I'm too lazy to spend time implementing this though since I'd rather use my time to review other problems for my Amazon on-site lol.....

    • @letscode1000
      @letscode1000 Před 5 měsíci

      I've justed checked in .com and .cn, they're both ok in python. here is the code, you can have check. class Solution: def longestValidSubstring(self, word: str, forbidden: List[str]) -> int: forbidden = set(forbidden) # n * m ** 2 l, res = 0, 0 for r in range(len(word)): for i in range(r, max(r - 10, l - 1), -1): if word[i: r + 1] in forbidden: l = i + 1 break res = max(res, r - l + 1) return res

  • @szain98
    @szain98 Před 5 měsíci

    This really helped me understand this problem better, thanks

  • @shubhamkamdi6606
    @shubhamkamdi6606 Před 5 měsíci

    Beautiful solution thank you for making a video for this problem

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

    Using python?

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

    Which language is it

  • @Leet.Time.
    @Leet.Time. Před 6 měsíci

    Thankyou for these videos great help

  • @chetnadhir
    @chetnadhir Před 8 měsíci

    hey if possible can u please guide my comp. sci journey , im a first year student

    • @letscode1000
      @letscode1000 Před 8 měsíci

      grasp one language such as Python, then be really good at cources of data structure and algorithms and algorithms design, then grind leetcode 75 and look for internship as early as possible

    • @chetnadhir
      @chetnadhir Před 8 měsíci

      @@letscode1000 thank you

  • @letscode1000
    @letscode1000 Před 9 měsíci

    It's the same for res = [] or self.res = [] for python global variable

  • @soumyajitganguly2593
    @soumyajitganguly2593 Před 9 měsíci

    "Answers within 10^-6 of the actual....." --> nice way to identify a potential Binary Search problem :) This would work for the Sqrt(n) problem too. But unfortunately not for Koko Banana or Aggressive Cows

    • @letscode1000
      @letscode1000 Před 9 měsíci

      yes, I agree, this problem is recognized by binary search not only by the 10^-6 but also the Minimize Max key word, in my video Koko eating banana: czcams.com/video/dPEimZw_BnQ/video.html, I also explained how to recognize as binary search + guess problems, the coding is easy, the hard part is to recognize the pattern.

  • @jezzdat2kk5
    @jezzdat2kk5 Před 9 měsíci

    wait i forgot about this one.Ty so much!!

    • @letscode1000
      @letscode1000 Před 9 měsíci

      it's a famous template problem in cs for practising dfs😄

    • @jezzdat2kk5
      @jezzdat2kk5 Před 9 měsíci

      @@letscode1000 yes i see

  • @thefinn0tube_
    @thefinn0tube_ Před 9 měsíci

    Nice work man, very clean solution. Your English and explanation is very good 👍

  • @letscode1000
    @letscode1000 Před 9 měsíci

    Space complexity O(mn), dfs will call at most m*n times

  • @philipmwangi5270
    @philipmwangi5270 Před 9 měsíci

    Hey, I love what you doing. Keep it up. Love the content.

  • @samvuong5613
    @samvuong5613 Před 9 měsíci

    Very good vid

  • @letscode1000
    @letscode1000 Před 10 měsíci

    Mistake for analyzing the r value, it should be 2 * 10 ** 8, not 10 ** 16, I made a mistake by 10 ** 8 + 10 ** 8 = 10 ** 16.

  • @letscode1000
    @letscode1000 Před 10 měsíci

    Time complexity is O(nlogn) not O(n), heappush and heappop is log(N)

  • @letscode1000
    @letscode1000 Před 10 měsíci

    correction: space complexity O(n*k)

  • @user-pt9vt4dj4x
    @user-pt9vt4dj4x Před 11 měsíci

    fire ❤❤❤❤

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

    i totally understand your logic.. can you give solution in c++

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

    Thank you, very well explained!

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

    A better solution is to use message as a buffer. class Logger: def __init__(self): self.logger_set = set() self.message_queue = deque() def shouldPrintMessage(self, timestamp: int, message: str) -> bool: while self.message_queue: oldest_message, oldest_time = self.message_queue[0] if timestamp - oldest_time >= 10: self.message_queue.popleft() self.logger_set.remove(oldest_message) else: break if message not in self.logger_set: self.logger_set.add(message) self.message_queue.append((message, timestamp)) return True else: return False

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

    Horrible. The map would keep grow until system is out of memory. This kind of implementation should be done using a ring buffer or something.

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

      good point, this is the buffer - the queue message application for solving the memory issues. class Logger: def __init__(self): self.logger_set = set() self.message_queue = deque() def shouldPrintMessage(self, timestamp: int, message: str) -> bool: while self.message_queue: oldest_message, oldest_time = self.message_queue[0] if timestamp - oldest_time >= 10: self.message_queue.popleft() self.logger_set.remove(oldest_message) else: break if message not in self.logger_set: self.logger_set.add(message) self.message_queue.append((message, timestamp)) return True else: return False