Knapsack
Knapsack
  • 40
  • 150 684
Coding Interview Problem - Extra Characters In A String
Code: Coming Soon
Solutions and video explanation to the commonly asked coding interview question: Extra Characters In A String. Leetcode Question: 2707
Chapters:
Understanding the Problem: 0:00
Solution 1: 1:30
Solution 2: 7:01
Solution 3: 9:26
Переглядів: 611

Відео

Coding Interview Problem - First Completely Painted Row or Column
Переглядів 353Рік тому
Code: knapsacklabs.netlify.app/course/coding_interview/algorithm/first_completely_painted_row_or_column Solutions and video explanation to the commonly asked coding interview question: First Completely Painted Row or Column. Leetcode Question: 2661 Chapters: Understanding the Problem: 0:00 Solution 1: 1:40 Solution 2: 4:44
Coding Interview Problem - Frequency Tracker
Переглядів 516Рік тому
Code: knapsacklabs.netlify.app/course/coding_interview/algorithm/frequency_tracker Solutions and video explanation to the commonly asked coding interview question: Frequency Tracker. Leetcode Question: 2671 Chapters: Understanding the Problem: 0:00 Solution 1: 1:55 Solution 2: 3:30
Coding Interview Problem - Two Non-overlapping Subarrays With Target
Переглядів 489Рік тому
Code: knapsacklabs.netlify.app/course/coding_interview/dynamic_programming/two_subarrays_with_target Solutions and video explanation to the commonly asked coding interview question: Two Non-overlapping Subarrays With Target Sum. Leetcode Question: 1477 Chapters: Understanding the Problem: 0:00 Solution 1: 0:59 Solution 2: 3:02
Coding Interview Problem - Maximum Length of Subarray With Positive Product
Переглядів 414Рік тому
Code: knapsacklabs.netlify.app/course/coding_interview/algorithm/maximum_length_of_subarray_with_positive_product Solutions and video explanation to the commonly asked coding interview question: Maximum Length of Subarray With Positive Product. Leetcode Question: 1567 Chapters: Understanding the Problem: 0:00 Solution 1: 0:44 Solution 2: 1:55
Coding Interview Problem - Maximum Points From Cards
Переглядів 249Рік тому
Code: knapsacklabs.netlify.app/course/coding_interview/algorithm/maximum_points_from_cards Solutions and video explanation to the commonly asked coding interview question: Maximum Points From Cards. Leetcode Question: 1423 Chapters: Understanding the Problem: 0:00 Solution 1: 1:14 Solution 2: 4:09
Coding Interview Problem - Find K Closest Elements
Переглядів 565Рік тому
Code: knapsacklabs.netlify.app/course/coding_interview/algorithm/find_k_closest_elements Solutions and video explanation to the commonly asked coding interview question: Find K Closest Elements.Leetcode Question: 658 Chapters: Understanding the Problem: 0:00 Solution 1: 0:49 Solution 2: 2:27
Coding Interview Problem - Product Of Array Except Self
Переглядів 167Рік тому
Code: knapsacklabs.netlify.app/course/coding_interview/algorithm/product_of_array_except_self Solutions and video explanation to the commonly asked coding interview question: Product Of Array Except Self. Leetcode Question: 238 Chapters: Understanding the Problem: 0:00 Solution 1: 1:02 Solution 2: 1:31 Solution 3: 3:55
Coding Interview Problem - Number of Matching Subsequences
Переглядів 2542 роки тому
Code: knapsacklabs.netlify.app/course/coding_interview/algorithm/number_of_matching_subsequences Solutions and video explanation to the commonly asked coding interview question: Number of Matching Subsequences. Leetcode Question: 792. Chapters: Understanding the Problem: 0:00 Solution 1: 0:36 Solution 2: 3:32
Coding Interview Problem - Unique Paths 2
Переглядів 2802 роки тому
Leetcode Question: 63 Solutions and video explanation to the commonly asked coding interview question: Unique Paths 2. Code can be found on KnapsackLabs website: knapsacklabs.netlify.app/course/coding_interview/dynamic_programming/unique_paths_2 Chapters: Understanding the Problem: 0:00 Solution 1: 0:54 Solution 2: 2:38 Solution 3: 3:27
Coding Interview Problem - Task Scheduler
Переглядів 7682 роки тому
Leetcode Question: 621 Solutions and video explanation to the commonly asked coding interview question: Task Scheduler. Code can be found on KnapsackLabs website: [In progress, link coming soon...] Chapters: Understanding the Problem: 0:00 Solution 1: 1:10
Coding Interview Problem - Minimum Path Sum
Переглядів 4952 роки тому
Leetcode Question: 64 Solutions and video explanation to the commonly asked coding interview question: Minimum Path Sum. Code can be found on KnapsackLabs website: [In progress, link coming soon...] Chapters: Understanding the Problem: 0:00 Solution 1: 0:28 Solution 2: 3:18 Solution 3: 4:17 If you like the video and found it useful please consider sharing it with other people who may be prepari...
Coding Interview Problem - Count All Possible Routes
Переглядів 5002 роки тому
Leetcode Question: 1575 Solutions and video explanation to the commonly asked coding interview question: Count All Possible Routes. Code can be found on KnapsackLabs website: [In progress, link coming soon...] Chapters: Understanding the Problem: 0:00 Solution 1: 1:27 Solution 2: 8:22 If you like the video and found it useful please consider sharing it with other people who may be preparing for...
Coding Interview Problem - Koko Eating Bananas
Переглядів 4342 роки тому
Leetcode Question: 875 Solutions and video explanation to the commonly asked coding interview question: Koko Eating Bananas. Code can be found on KnapsackLabs website: [In progress, link coming soon...] Chapters: Understanding the Problem: 0:00 Solution 1: 2:20 Solution 2: 5:28 If you like the video and found it useful please consider sharing it with other people who may be preparing for the te...
Coding Interview Problem - Critical Connections In Network
Переглядів 3422 роки тому
Leetcode Question: 1192 Solutions and video explanation to the commonly asked coding interview question: Critical Connections In Network. Code can be found on KnapsackLabs website: [In progress, link coming soon...] Chapters: Understanding the Problem: 0:00 Solution 1: 1:49 Solution 2: 2:50 If you like the video and found it useful please consider sharing it with other people who may be prepari...
Coding Interview Problem - Hand Of Straights
Переглядів 3782 роки тому
Coding Interview Problem - Hand Of Straights
Coding Interview Problem - Asteroid Collision
Переглядів 3252 роки тому
Coding Interview Problem - Asteroid Collision
Coding Interview Problem - Car Fleet
Переглядів 1 тис.2 роки тому
Coding Interview Problem - Car Fleet
Coding Interview Problem - Longest String Chain
Переглядів 3392 роки тому
Coding Interview Problem - Longest String Chain
Coding Interview Problem - RLE Iterator
Переглядів 6072 роки тому
Coding Interview Problem - RLE Iterator
Coding Interview Problem - Knight Probability in Chessboard
Переглядів 4,4 тис.3 роки тому
Coding Interview Problem - Knight Probability in Chessboard
Coding Interview Problem - Prison Cells After N Days
Переглядів 9084 роки тому
Coding Interview Problem - Prison Cells After N Days
Coding Interview Problem - Next Greater Element II
Переглядів 4,2 тис.4 роки тому
Coding Interview Problem - Next Greater Element II
Coding Interview Problem - Next Greater Element I
Переглядів 8854 роки тому
Coding Interview Problem - Next Greater Element I
Coding Interview Problem - Shortest Path With Obstacle Elimination
Переглядів 16 тис.4 роки тому
Coding Interview Problem - Shortest Path With Obstacle Elimination
Coding Interview Problem - Bulb Switcher III
Переглядів 2,5 тис.4 роки тому
Coding Interview Problem - Bulb Switcher III
Coding Interview Problem - Subarray Sum Equals K
Переглядів 8 тис.4 роки тому
Coding Interview Problem - Subarray Sum Equals K
Coding Interview Problem - Decode Ways
Переглядів 19 тис.4 роки тому
Coding Interview Problem - Decode Ways
Coding Interview Problem - Gas Station
Переглядів 22 тис.4 роки тому
Coding Interview Problem - Gas Station
Coding Interview Problem - First Missing Positive
Переглядів 2,6 тис.4 роки тому
Coding Interview Problem - First Missing Positive

КОМЕНТАРІ

  • @icemonkeyeffect
    @icemonkeyeffect Місяць тому

    best explanation so far :) thanks

  • @Mrflippy4
    @Mrflippy4 2 місяці тому

    Great great great! 👏

  • @MedhatR-do9le
    @MedhatR-do9le 3 місяці тому

    great explantation thanks

  • @sanshubhkukutla4043
    @sanshubhkukutla4043 3 місяці тому

    Great explanation thanks!

  • @pranavkumar1818
    @pranavkumar1818 3 місяці тому

    Nice explanation man !

  • @Martinnnnnn-e5s
    @Martinnnnnn-e5s 5 місяців тому

    After watching like 5 videos about this question finally there's one that i understand. amazing explantion

  • @Alex-tm5hr
    @Alex-tm5hr 5 місяців тому

    Just a heads up - this is for LC Combination Sum IV.

  • @drewlee7435
    @drewlee7435 6 місяців тому

    literally THE best explanation i've seen

  • @janpoonthong
    @janpoonthong 6 місяців тому

    Great video

  • @AnarchySane
    @AnarchySane 9 місяців тому

    Great. Thank you very much❤

  • @ivandrofly
    @ivandrofly 9 місяців тому

    Thanks

  • @manwinsingh7381
    @manwinsingh7381 10 місяців тому

    Bro. You made my day. I was exhausted by this problem and couldn't find a correct explanation. Your dry runs and explanation were way too smooth. Thank you so much.

  • @velakuruday
    @velakuruday 11 місяців тому

    Thank you brother. Only you explained why the i-1 + i-2 is valid.

  • @subee128
    @subee128 11 місяців тому

    Thank you very much

  • @subee128
    @subee128 11 місяців тому

    Thank you

  • @subee128
    @subee128 11 місяців тому

    Thank you

  • @subee128
    @subee128 11 місяців тому

    Thank you very much

  • @subee128
    @subee128 11 місяців тому

    Thank you

  • @subee128
    @subee128 11 місяців тому

    Thank you

  • @subee128
    @subee128 11 місяців тому

    Thank you very much

  • @subee128
    @subee128 11 місяців тому

    Thank you

  • @subee128
    @subee128 11 місяців тому

    Thank you very much

  • @subee128
    @subee128 11 місяців тому

    Thank you very much

  • @subee128
    @subee128 11 місяців тому

    Thank you very much

  • @subee128
    @subee128 11 місяців тому

    Thank you very much

  • @subee128
    @subee128 11 місяців тому

    Thanks

  • @shahzadsaleem8142
    @shahzadsaleem8142 11 місяців тому

    Perfect explanation of recursion

  • @subee128
    @subee128 11 місяців тому

    Thanks

  • @subee128
    @subee128 Рік тому

    Thanks

  • @subee128
    @subee128 Рік тому

    Thanks

  • @noble.things
    @noble.things Рік тому

    Thanks so much for the excellent explanation of the problem. It really crystallized it for me. That being said, it seems there might be a bug in the code though. In the case where there are no collisions (i.e. no car catches up to another car), the resulting fleet count should be the total number of cars (since each individual car is a fleet), but based on this code, it will be 1. Disclaimer: I didn't actually run the code, but just from looking at it, "fleet_count" is initialized to zero and incremented only when there's a collision, and once again after exiting the "for" loop. Unless I’m missing something….

  • @AnkurTeotia9600
    @AnkurTeotia9600 Рік тому

    this is the most inituitive solution out of all solutions present for this problem imo.

  • @a_maxed_out_handle_of_30_chars

    so good, thank you :)

  • @gradientO
    @gradientO Рік тому

    best explanation for this question!

  • @AlvaroGarcia-fb6oh
    @AlvaroGarcia-fb6oh Рік тому

    First video that helped me understand the tabulation solution! Thanks a lot man.

  • @hashtagcc
    @hashtagcc Рік тому

    Ur videos are awesome pls post more videos

  • @floatingpoint7629
    @floatingpoint7629 Рік тому

    you should also do a dry run of the code on sample input. just looking at code does not help understand

  • @prakhyat2001
    @prakhyat2001 Рік тому

    thanks a lot

  • @VivekSingh99
    @VivekSingh99 Рік тому

    I have been trying to understand this question for the entire day and I FINALLY GET IT. Thank you this is so well put together.

  • @light7958
    @light7958 Рік тому

    thanks! easy to understand

  • @EMAWgasm
    @EMAWgasm Рік тому

    Nice! I didn't think to flip the integers to negative, but when you did that, something else in my brain clicked. If we keep a running sum of the index + (-array[index]), then we know that the lights will all be energized if this sum == 0, so I came up with something like this: int count = 0 int energized = 0 for (int i = 0; i < array.Length; i++) { energized += i + 1; energized += -array[i]; if (energized == 0) count++; } return count; I know this vid is like 2 years old, but thought I'd share in case anyone else stumbles upon this.

  • @obedpadilla5264
    @obedpadilla5264 Рік тому

    I finally managed to make my own implementation in java with my limited programming knowledge haha import java.util.Arrays; public class CarFleet { public static void main(String[] args) { int carDistance = 12; int[] carPositions = {2, 0, 4, 7}; int[] carSpeeds = {4, 1, 2, 1}; System.out.println(countCarFleets(carDistance, carPositions, carSpeeds)); // expected fleets: 2 } public static int countCarFleets(int distance, int[] position, int[] speed) { int countFleets = 0; int[] carPositions = position.clone(); int[] carSpeeds = new int[speed.length]; Arrays.sort(carPositions); for(int i = 0; i < carSpeeds.length; ++i) { int index = Arrays.binarySearch(carPositions, position[i]); carSpeeds[index] = speed[i]; } int timeFront = (distance - carPositions[carPositions.length - 1]) / carSpeeds[carSpeeds.length - 1]; for(int i = carSpeeds.length - 2; i > -1; --i) { int timeBack = (distance - carPositions[i]) / carSpeeds[i]; if(timeBack > timeFront) { ++countFleets; timeFront = timeBack; } } return ++countFleets; } }

  • @chemistryman6053
    @chemistryman6053 Рік тому

    please increase the font size

    • @KnapsackLabs
      @KnapsackLabs Рік тому

      Done in future videos! Thanks for the feedback.

  • @bluesteel1
    @bluesteel1 Рік тому

    Nice video

  • @mohammedabulsoud1819
    @mohammedabulsoud1819 Рік тому

    Thanks!

  • @parthpatel4980
    @parthpatel4980 Рік тому

    ur the goat! u saved my life

  • @marspark6351
    @marspark6351 2 роки тому

    The sound is not synced with the video starting from 6:33. Would be nice if you can correct it

  • @PremPal-uy4nm
    @PremPal-uy4nm 2 роки тому

    Hey man, I was stuck at LeetCode Gas Station problem from past 3 days. It almost felt like I am doing some kind of research on this problem. Somehow I found your video. I finally understood the optimized solution. Thank you so much. Liked your video and subscribed. Can you tell me how you were able to find solution to that problem? / Did you take any help from books, video or any resource or yourself? What do you recommend, How should someone approach to solve this kind of problem or just understand the solution(optimized solution of gas station)? I am commenting on your latest video, so that I can have your attention. Love you man! From India.

  • @PremPal-uy4nm
    @PremPal-uy4nm 2 роки тому

    Thank You! Thank You! Thank You! I can finally die in peace.

  • @neo9530
    @neo9530 2 роки тому

    Thank you! Finally I can die in peace.