Algorithms Casts
Algorithms Casts
  • 671
  • 385 068
Leetcode 1701: Average Waiting Time
#leetcodechallenge #coding #algorithms
🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts
🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice
Problem: leetcode.com/problems/average-waiting-time/description/
#leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #codinginterview #googleinterview
⭐ ⭐ MEDUIM LEETCODE PROBLEMS EXPLANATIONS: czcams.com/video/m0J1Q2EbvOc/video.html
⭐ ⭐ ⭐ HARD LEETCODE PROBLEMS EXPLANATIONS: czcams.com/video/EzDnB7Ayv08/video.html
▬▬▬▬▬▬▬▬▬▬▬▬
leetcode weekly contest, weekly contest, leetcode, google coding interview, Leetcode 1701, leetcode 1701, Leetcode 1701: Average Waiting Time,
Leetcode 1701. Average Waiting Time, Average Waiting Time, biweekly contest, weekly contest, daily leetcode challenge, neetcode, neetcodeio, larry, bit manipulation, binary, xor operation, breadth first search, bfs, recursion, mathtwo pointers, string, binary manipulation, bit manipulation, binary, recursion, dynamic programming, kmp, prefix, string, prefix, suffix, brute force, matrix,geometry, brute force, prefix sum, hashmap brute force, sliding window, mean heap, geapq,
zhlédnutí: 12

Video

Leetcode 1823: Find the Winner of the Circular Game
zhlédnutí 32Před 2 hodinami
#leetcodechallenge #coding #algorithms 🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/find-the-winner-of-the-circular-game/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #codinginterview ...
Leetcode 3208: Alternating Groups II
zhlédnutí 26Před 4 hodinami
#leetcodechallenge #coding #algorithms 🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/alternating-groups-ii/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #codinginterview #googleintervie...
Leetcode 3212. Count Submatrices With Equal Frequency of X and Y
zhlédnutí 58Před 4 hodinami
#leetcodechallenge #coding #algorithms 🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/count-submatrices-with-equal-frequency-of-x-and-y/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #cod...
Leetcode 3211: Generate Binary Strings Without Adjacent Zeros
zhlédnutí 76Před 4 hodinami
#leetcodechallenge #coding #algorithms 🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/generate-binary-strings-without-adjacent-zeros/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #coding...
Leetcode 1518: Water Bottles
zhlédnutí 111Před 4 hodinami
#leetcodechallenge #coding #algorithms 🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/water-bottles/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #codinginterview #googleinterview ⭐ ⭐ ME...
Leetcode 3207: Maximum Points After Enemy Battles
zhlédnutí 54Před 7 hodinami
#leetcodechallenge #coding #algorithms 🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/maximum-points-after-enemy-battles/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #codinginterview #g...
Leetcode 3206 Alternating Groups I
zhlédnutí 39Před 7 hodinami
🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/alternating-groups-i/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #codinginterview #googleinterview ⭐ ⭐ MEDUIM LEETCODE PROBLEMS EXPLANATI...
Leetcode 2582: Pass the Pillow
zhlédnutí 143Před 7 hodinami
🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/pass-the-pillow/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #codinginterview #googleinterview ⭐ ⭐ MEDUIM LEETCODE PROBLEMS EXPLANATIONS: ...
Leetcode 2058: Find the Minimum and Maximum Number of Nodes Between Critical Points
zhlédnutí 41Před 9 hodinami
🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #codinginterview #google...
Leetcode 2037: Minimum Number of Moves to Seat Everyone
zhlédnutí 90Před 21 dnem
🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/minimum-number-of-moves-to-seat-everyone/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #codinginterview #googleinterview ⭐ ⭐ MEDUIM LEETCOD...
Leetcode 75: Sort Colors
zhlédnutí 60Před 21 dnem
🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/sort-colors/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #codinginterview #googleinterview ⭐ ⭐ MEDUIM LEETCODE PROBLEMS EXPLANATIONS: czca...
Leetcode 3180: Maximum Total Reward Using Operations I
zhlédnutí 132Před 28 dny
This week's leetcode weekly contest: Weekly Contest 401 🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/maximum-total-reward-using-operations-i/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorit...
Leetcode 1122: Relative Sort Array
zhlédnutí 50Před 28 dny
🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/relative-sort-array/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #codinginterview #googleinterview ⭐ ⭐ MEDUIM LEETCODE PROBLEMS EXPLANATIO...
Leetcode 3179: Find the N-th Value After K Seconds
zhlédnutí 94Před 28 dny
🥷 1:1 coding interviews and leetcode problems coaching, Book a session with me on Superpeer: superpeer.com/algorithmscasts 🐮 Support the channel on Patreon: www.patreon.com/algorithmspractice Problem: leetcode.com/problems/find-the-n-th-value-after-k-seconds/description/ #leetcode #python #leetcodedailychallenge #leetcodedaily #algorithm #codinginterview #googleinterview ⭐ ⭐ MEDUIM LEETCODE PRO...
Leetcode 3178: Find the Child Who Has the Ball After K Seconds
zhlédnutí 84Před 28 dny
Leetcode 3178: Find the Child Who Has the Ball After K Seconds
Leetcode 1051: Height Checker
zhlédnutí 50Před 28 dny
Leetcode 1051: Height Checker
Leetcode 846: Hand of Straights
zhlédnutí 37Před měsícem
Leetcode 846: Hand of Straights
Leetcode 1002: Find Common Characters
zhlédnutí 36Před měsícem
Leetcode 1002: Find Common Characters
Leetcode 2441: Largest Positive Integer That Exists With Its Negative
zhlédnutí 128Před 2 měsíci
Leetcode 2441: Largest Positive Integer That Exists With Its Negative
Leetcode 2000: Reverse Prefix of Word
zhlédnutí 96Před 2 měsíci
Leetcode 2000: Reverse Prefix of Word
Leetcode 988: Smallest String Starting From Leaf
zhlédnutí 62Před 2 měsíci
Leetcode 988: Smallest String Starting From Leaf
Leetcode 129: Sum Root to Leaf Numbers
zhlédnutí 78Před 2 měsíci
Leetcode 129: Sum Root to Leaf Numbers
Leetcode 404: Sum of Left Leaves
zhlédnutí 111Před 2 měsíci
Leetcode 404: Sum of Left Leaves
Leetcode 402: Remove K Digits
zhlédnutí 97Před 2 měsíci
Leetcode 402: Remove K Digits
Leetcode 2073: Time Needed to Buy Tickets
zhlédnutí 37Před 3 měsíci
Leetcode 2073: Time Needed to Buy Tickets
Leetcode 1700: Number of Students Unable to Eat Lunch
zhlédnutí 61Před 3 měsíci
Leetcode 1700: Number of Students Unable to Eat Lunch
Leetcode 1614: Maximum Nesting Depth of the Parentheses
zhlédnutí 41Před 3 měsíci
Leetcode 1614: Maximum Nesting Depth of the Parentheses
Leetcode 205: Isomorphic Strings
zhlédnutí 62Před 3 měsíci
Leetcode 205: Isomorphic Strings
Leetcode 3101: Count Alternating Subarrays
zhlédnutí 130Před 3 měsíci
Leetcode 3101: Count Alternating Subarrays

Komentáře

  • @abhishekmittal1302

    so it means i was able to solve 90% of this problem on my own but i rather than dividing c/e[0], i was doing every loop which gave me tle. and whole time during contest i was thinking how to even convert it into O(N) 🙂

  • @gaureesha9840
    @gaureesha9840 Před 2 dny

    thanks!!

  • @mhashmi3593
    @mhashmi3593 Před 3 dny

    No idea about the other solutions you've solved. But this one is really simplified and nice way to explain. You've made it piece of cake and I was able to solve few other hard Leetcode questions with simply by swaps. Keep it up don't worry about number of views or comments. Cheers

  • @deep8843
    @deep8843 Před 3 dny

    good explanation

  • @jnayehsirine6222
    @jnayehsirine6222 Před 6 dny

    best video for this problem ! thhanks

  • @apbh
    @apbh Před 7 dny

    Thank you for this simple explanation!

  • @yr4580
    @yr4580 Před 7 dny

    Thanks, great description.

  • @anoops7974
    @anoops7974 Před 17 dny

    Thank you so much. I love the clean solution. Subscribed, looking forward to see more videos from you in coming days.

  • @achaljain9973
    @achaljain9973 Před 17 dny

    Hi ! Thanks for the awesome explanation The above code fails for one test case (might have been upated) words = ["A","B"] , result = "A". I think the what they mean by no leading zeors is valid if the number if of length >= 2. Here we can see that the requirement is that B has to be zero!. Hence no leadning zeroes is applicable only if len(word) > 1. 2 minor fixes fixed the code for me. One was this : here we can use 0 even if the column == len(word)-1 if and only if the word is itself of length 1 # digit assignment already exists -> use it if letter in letterToDigit and not (letterToDigit[letter] == 0 and column == len(word) - 1 and len(word) > 1): return search(column, row + 1, bal + sign * letterToDigit[letter]) The other fix was Here we skip zero assignment even if column == len(words)-1 if and only if len(words) > 1. for d, c in enumerate(digitToLetter): if c is None: # the second condition is to prevent leading 0s if d == 0: if len(word) > 1 and column == len(word)-1: continue Again, thanks for the awesome explanation.

  • @user-ys6ro4wi3f
    @user-ys6ro4wi3f Před 19 dny

    Thank you!

  • @solvinglife6658
    @solvinglife6658 Před 21 dnem

    Very important. ❤great

  • @harshit_nimesh
    @harshit_nimesh Před 21 dnem

    that's just awesome. I was confused over the prefix sum In 2d array

  • @tinal3991
    @tinal3991 Před 22 dny

    From minite around 22, I believe in the matrix, should be "(i+1, k +1)"

  • @abhilashpatel3036
    @abhilashpatel3036 Před 23 dny

    I could not understand why you did return min(money/7, children -1)? money/7 would occur when money/7< children and children-1would occur when money/7 > children. so how you put both condition in one line?

  • @Sam-gx9xl
    @Sam-gx9xl Před 25 dny

    U explained the concept very well thank u for helping out

  • @juanmacias5922
    @juanmacias5922 Před 26 dny

    whoa! I had never noticed LT has a button that analyzes the time complexity for us!

  • @bryangrounds9341
    @bryangrounds9341 Před 27 dny

    Thanks for the explanation! I was unable to come up with a (sub O(N^2)) solution on my own, and reading LeetCode's explanation several times didn't help. This is good.

  • @dampdigits.69
    @dampdigits.69 Před 28 dny

    Thank you so much ❤

  • @MadhukarBhaktha-mw8yb

    thank You

  • @ALONEWILL
    @ALONEWILL Před 29 dny

    Welcome back 🎉

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

    thank you, great explanation

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

    You're Impressive. thank you <3

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

    THANK YOU

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

    Thank you so much for your nice explanation, it really is easy.

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

    The cleanest and readable solution I've seen for this problem, thanks

  • @user-wh7zk9sh8y
    @user-wh7zk9sh8y Před 2 měsíci

    Doing great job with sharing best and easy solution !!

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

    I think we can sort and get the last element in array which is largest and compare with first element of array which should be smalest then if abs both are equal then reutrn true , btw i am fan of your thinking startegy 🎉❤

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

    this so diifcult,

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

    I used a deque, and appended left until found, then regular append :D returned word if not found.

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

    we are lucy to have you

  • @RezaFarahani-dw9jj
    @RezaFarahani-dw9jj Před 2 měsíci

    Masterpiece explanation. I did this one in BFS but I like your way much better. Math is the best.

  • @jeevansch.5599
    @jeevansch.5599 Před 2 měsíci

    Great solution. Your explanation is really great. :)

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

    This is amazing! This is the sort of solution I was looking for!

  • @dima.garotas
    @dima.garotas Před 2 měsíci

    Hi! Thanks a lot for this solution and explanation, can you please explain a little bit more about complexity. Why is it R*log(R*n) if we do while loop logR times and inside loop we do 2*n operations (calling function f twice) it should be something like n*logR, shouldn't it?

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

    thanks for the explanation. A quick question : The approach you mentioned here is DFS or BFS? because you have a queue as we use in BFS but then you don't visit all nodes in a list first so it's not level by level.

  • @RohanSingh-my3nl
    @RohanSingh-my3nl Před 2 měsíci

    Good Explain

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

    Elegant answer and explanation! You earned my like.

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

    Great explanation :D

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

    Slm, thanks for the explanations, I was looking for this problem's Moore Algorithm explanation, but you didn't mention it here, tho I saw that you talked about it in an older video.. but I had difficulties following it.., and the follow-up for the problem was O(n) time and O(1) space, anyways thanks alot! Eid Sa3id!

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

      Thank you, i'll consider doing another Moore Algorithm video, Eid Mubarak :)

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

      @@algorithmscasts902 thanks to you :D, i'm still struggling understanding it so i would appreciate it, thanks again!

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

    thank you so much

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

    Wow, this was a very good explanation. I'm so glad you posted it in the editorial because it is much better than the leetcode solution!!

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

    very easy to understand and implement

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

    Thank you! Your explanations are really good! They are the best( along with the channel codingMohan) I have seen on CZcams including popular channels like Neetcode,TakeuForward etc. Wish you would get more viewers!

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

    was waiting for it, please do all of the contest problems

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

    nice one

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

    can you give a formal proof of why only the minimum frequency character is the optimum. I get that it should be minimum only but can't prove it.

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

    This is a non optimal solution. If there are N instances of c, the first N has a substring beginning with it and ending with all N instances of c. The next one has N - 1, etc. So you just need to count the instances of c, then take the sum of i from 0 to N, which is N(N + 1)/2. I wrote this in under 30 seconds and it solves the problem by checking each character exactly once, using a single integer variable, and doing a few arithmetic operations. pasteboard.co/3Rlb5RMsDyVr.png

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

    Great 🇧🇩

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

    There is a subtle detail here that is very easy to miss and also the genius part of this solution. Conventional logic dictates that we would find the max digit, record how many digits there were in the number and then start multiplying the max digit with powers of 10 for however many digits we get. For example, if our number is 523, our mx = 5 and count is 3. So we would do something like 5*10^0 + 5*10^1 + 5*10^2 = 5 + 50 + 500 = 555. Instead of doing that, all we want is the max digit in all places. So how about we build up the number in such a way that we have 1's everywhere and that is what line 12 is doing and the subtle part of the solution. What we are doing is actually building a number with 1's in all places equal to however many digits we have while finding the max digit at the same time. In our example of 523, our mul at the end of the while loop is actually 111 (replaced all digits with just 1's) and after that, we are guaranteed to have our max digit, so just multiply 111 with 5 to get 555.

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

    This is so much more complicated than it needs to be.... Your solution is O(n) in both time and memory complexity. Technically it's 2 * O(n) because you're doing 2 loops. As one commenter said, startsWith and endsWith arrays are the same. Then you can notice that if the startsWith array has 4 elements, we will have the following: - For the element at index 0 in the startsWith array, you will have 4 substring: 0-0, 0-1, 0-2, 0-3. - For the element at index 1, you will have 1-1, 1-2, 1-3 - Then 2-2, 2-3 - Finally 3-3. This is 4 + 3 + 2 + 1. So you can notice that the solution will just be sum of all numbers up to the number of occurrences, aka (n * n(+1) ) / 2. So you can just have a single integer `numberOfOccurrencesOfC`, you traverse the `s` array and increment this counter each time you find a `c`. In the end you `return (numberOfOccurrencesOfC * (numberOfOccurrencesOfC + 1)) / 2`. O(n) time complexity, 1 memory complexity. ---- Though in an interview setting, I'm not sure if they would give you more points, because you "walked them through iterations of solutions" vs me who just immediately went through all the thinking in 2minutes, and arrived at the above solution without saying much.