NeetCodeIO
NeetCodeIO
  • Видео 407
  • Просмотров 9 096 019
Minimum Increment to Make Array Unique - Leetcode 945 - Python
🚀 neetcode.io/ - A better way to prepare for Coding Interviews
🧑‍💼 LinkedIn: www.linkedin.com/in/navdeep-singh-3aaa14161/
🐦 Twitter: neetcode1
⭐ BLIND-75 PLAYLIST: ruclips.net/video/KLlXCFG5TnA/видео.html
Problem Link: leetcode.com/problems/minimum-increment-to-make-array-unique/description/
0:00 - Read the problem
0:30 - Drawing Explanation
5:47 - Coding Explanation
7:43 - Drawing Explanation
14:14 - Coding Explanation
leetcode 945
#neetcode #leetcode #python
Просмотров: 11 237

Видео

Minimum Number of Moves to Seat Everyone - Leetcode 2037 - Python
Просмотров 6 тыс.17 часов назад
🚀 neetcode.io/ - A better way to prepare for Coding Interviews 🧑‍💼 LinkedIn: www.linkedin.com/in/navdeep-singh-3aaa14161/ 🐦 Twitter: neetcode1 ⭐ BLIND-75 PLAYLIST: ruclips.net/video/KLlXCFG5TnA/видео.html Problem Link: leetcode.com/problems/minimum-number-of-moves-to-seat-everyone/description/ 0:00 - Read the problem 0:30 - Drawing Explanation 8:42 - Coding Explanation leetcode 2037...
Relative Sort Array - Leetcode 1122 - Python
Просмотров 8 тыс.22 часа назад
🚀 neetcode.io/ - A better way to prepare for Coding Interviews 🧑‍💼 LinkedIn: www.linkedin.com/in/navdeep-singh-3aaa14161/ 🐦 Twitter: neetcode1 ⭐ BLIND-75 PLAYLIST: ruclips.net/video/KLlXCFG5TnA/видео.html Problem Link: leetcode.com/problems/relative-sort-array/description/ 0:00 - Read the problem 0:30 - Drawing Explanation 4:42 - Coding Explanation leetcode 1122 #neetcode #leetcode ...
Height Checker - Leetcode 1051 - Python
Просмотров 7 тыс.День назад
🚀 neetcode.io/ - A better way to prepare for Coding Interviews 🧑‍💼 LinkedIn: www.linkedin.com/in/navdeep-singh-3aaa14161/ 🐦 Twitter: neetcode1 ⭐ BLIND-75 PLAYLIST: ruclips.net/video/KLlXCFG5TnA/видео.html Problem Link: leetcode.com/problems/height-checker/description/ 0:00 - Read the problem 0:30 - Drawing Explanation 5:16 - Coding Explanation leetcode 1051 #neetcode #leetcode #python
Subarray Sums Divisible by K - Leetcode 974 - Python
Просмотров 11 тыс.День назад
🚀 neetcode.io/ - A better way to prepare for Coding Interviews 🧑‍💼 LinkedIn: www.linkedin.com/in/navdeep-singh-3aaa14161/ 🐦 Twitter: neetcode1 ⭐ BLIND-75 PLAYLIST: ruclips.net/video/KLlXCFG5TnA/видео.html Problem Link: leetcode.com/problems/subarray-sums-divisible-by-k/description/ 0:00 - Read the problem 0:30 - Drawing Explanation 14:30 - Coding Explanation leetcode 974 #neetcode #...
Find Common Characters - Leetcode 1002 - Python
Просмотров 10 тыс.День назад
🚀 neetcode.io/ - A better way to prepare for Coding Interviews 🧑‍💼 LinkedIn: www.linkedin.com/in/navdeep-singh-3aaa14161/ 🐦 Twitter: neetcode1 ⭐ BLIND-75 PLAYLIST: ruclips.net/video/KLlXCFG5TnA/видео.html Problem Link: leetcode.com/problems/find-common-characters/ 0:00 - Read the problem 0:30 - Drawing Explanation 7:20 - Coding Explanation leetcode 1002 #neetcode #leetcode #python
Longest Palindrome - Leetcode 409 - Python
Просмотров 9 тыс.День назад
🚀 neetcode.io/ - A better way to prepare for Coding Interviews 🧑‍💼 LinkedIn: www.linkedin.com/in/navdeep-singh-3aaa14161/ 🐦 Twitter: neetcode1 ⭐ BLIND-75 PLAYLIST: ruclips.net/video/KLlXCFG5TnA/видео.html Problem Link: leetcode.com/problems/longest-palindrome/ 0:00 - Read the problem 0:30 - Drawing Explanation 6:57 - Coding Explanation leetcode 409 #neetcode #leetcode #python
Append Characters to Strings to Make Subsequence - Leetcode 2486 - Python
Просмотров 6 тыс.День назад
🚀 neetcode.io/ - A better way to prepare for Coding Interviews 🧑‍💼 LinkedIn: www.linkedin.com/in/navdeep-singh-3aaa14161/ 🐦 Twitter: neetcode1 ⭐ BLIND-75 PLAYLIST: ruclips.net/video/KLlXCFG5TnA/видео.html Problem Link: leetcode.com/problems/append-characters-to-string-to-make-subsequence/description/ 0:00 - Read the problem 0:30 - Drawing Explanation 5:26 - Coding Explanation leetco...
Score of a String - Leetcode 3110 - Python
Просмотров 6 тыс.14 дней назад
🚀 neetcode.io/ - A better way to prepare for Coding Interviews 🧑‍💼 LinkedIn: www.linkedin.com/in/navdeep-singh-3aaa14161/ 🐦 Twitter: neetcode1 ⭐ BLIND-75 PLAYLIST: ruclips.net/video/KLlXCFG5TnA/видео.html Problem Link: leetcode.com/problems/score-of-a-string/ 0:00 - Drawing Explanation 2:45 - Coding Explanation leetcode 3110 #neetcode #leetcode #python
Single Number III - Leetcode 260 - Python
Просмотров 9 тыс.14 дней назад
🚀 neetcode.io/ - A better way to prepare for Coding Interviews 🧑‍💼 LinkedIn: www.linkedin.com/in/navdeep-singh-3aaa14161/ 🐦 Twitter: neetcode1 ⭐ BLIND-75 PLAYLIST: ruclips.net/video/KLlXCFG5TnA/видео.html Problem Link: leetcode.com/problems/single-number-iii/description/ 0:00 - Read the problem 1:30 - Drawing Explanation 9:17 - Coding Explanation leetcode 260 #neetcode #leetcode #py...
Count Triplets That Can Form Two Arrays of Equal XOR - Leetcode 1442 - Python
Просмотров 8 тыс.14 дней назад
Count Triplets That Can Form Two Arrays of Equal XOR - Leetcode 1442 - Python
Number of Steps to Reduce a Number in Binary Representation to One - Leetcode 1404 - Python
Просмотров 7 тыс.14 дней назад
Number of Steps to Reduce a Number in Binary Representation to One - Leetcode 1404 - Python
Get Equal Substrings Within Budget - Leetcode 1208 - Python
Просмотров 7 тыс.14 дней назад
Get Equal Substrings Within Budget - Leetcode 1208 - Python
Special Array with X Elements Greater than or Equal X - Leetcode 1608 - Python
Просмотров 9 тыс.14 дней назад
Special Array with X Elements Greater than or Equal X - Leetcode 1608 - Python
How I would learn Leetcode if I could start over
Просмотров 218 тыс.21 день назад
How I would learn Leetcode if I could start over
Student Attendance Record II - Leetcode 552 - Python
Просмотров 8 тыс.21 день назад
Student Attendance Record II - Leetcode 552 - Python
Word Break II - Leetcode 140 - Python
Просмотров 10 тыс.21 день назад
Word Break II - Leetcode 140 - Python
Maximum Score Words Formed By Letters - Leetcode 1255 - Python
Просмотров 9 тыс.21 день назад
Maximum Score Words Formed By Letters - Leetcode 1255 - Python
The Number of Beautiful Subsets - Leetcode 2597 - Python
Просмотров 9 тыс.21 день назад
The Number of Beautiful Subsets - Leetcode 2597 - Python
Sum of All Subsets XOR Total - Leetcode 1863 - Python
Просмотров 8 тыс.21 день назад
Sum of All Subsets XOR Total - Leetcode 1863 - Python
Find the Maximum Sum of Node Values - Leetcode 3068 - Python
Просмотров 13 тыс.28 дней назад
Find the Maximum Sum of Node Values - Leetcode 3068 - Python
Distribute Coins in Binary Tree - Leetcode 979 - Python
Просмотров 14 тыс.28 дней назад
Distribute Coins in Binary Tree - Leetcode 979 - Python
Delete Leaves With a Given Value - Leetcode 1325 - Python
Просмотров 6 тыс.28 дней назад
Delete Leaves With a Given Value - Leetcode 1325 - Python
Evaluate Boolean Binary Tree - Leetcode 2331 - Python
Просмотров 7 тыс.Месяц назад
Evaluate Boolean Binary Tree - Leetcode 2331 - Python
Find the Safest Path in a Grid - Leetcode 2812 - Python
Просмотров 11 тыс.Месяц назад
Find the Safest Path in a Grid - Leetcode 2812 - Python
Path with Maximum Gold - Leetcode 1219 - Python
Просмотров 8 тыс.Месяц назад
Path with Maximum Gold - Leetcode 1219 - Python
Score After Flipping Matrix - Leetcode 861 - Python
Просмотров 9 тыс.Месяц назад
Score After Flipping Matrix - Leetcode 861 - Python
Largest Local Values in a Matrix - Leetcode 2373 - Python
Просмотров 7 тыс.Месяц назад
Largest Local Values in a Matrix - Leetcode 2373 - Python
Minimum Cost to Hire K Workers - Leetcode 857 - Python
Просмотров 12 тыс.Месяц назад
Minimum Cost to Hire K Workers - Leetcode 857 - Python
Remove Nodes From Linked List - Leetcode 2487 - Python
Просмотров 9 тыс.Месяц назад
Remove Nodes From Linked List - Leetcode 2487 - Python

Комментарии

  • @pratikawate5826
    @pratikawate5826 13 часов назад

    Still confused over infinite loop😅

  • @zakariya9898
    @zakariya9898 13 часов назад

    DSA brain rot

  • @viinisaari
    @viinisaari 15 часов назад

    Just take a data structures and algorithms class instead, Im begging you

  • @prathamvardaan4187
    @prathamvardaan4187 16 часов назад

    THANKS DUDE FOR THE ADVICE

  • @astroboiscosmos406
    @astroboiscosmos406 20 часов назад

    Best explanation

  • @akashdey5637
    @akashdey5637 22 часа назад

    why does the dfs call return the number of current passengers?

  • @alexdev404
    @alexdev404 23 часа назад

    This dude literally looks like me

  • @xxbighotshotxx
    @xxbighotshotxx День назад

    I never would have thought of this solution. Thank you

  • @alarmolord
    @alarmolord День назад

    The correct time complexity is O(n⋅log n + k⋅log n) when you take into account the `heapq.heapify(minCapital)` call.

  • @dera_ng
    @dera_ng День назад

    I've been a bit rusty with leetcode for sometime because of finals exams at school, I've still been trying to do leetcode fairly regularly, however, Immediately you mentioned using another heap for accessing other profits, my heart broke..... I came up with a solution that passed all the test cases except the last remaining 2 with the expected error being (Time Limit Exceeded).... I knew exactly what my problem was (which was updating what projects we have access to now that MIB aka money in the bank has increased).... THANKS!!!!! I wonder what topic in computer science theory could have helped with me thinking about this much faster (🤔)

  • @rezakaaccount
    @rezakaaccount День назад

    Leetcode is also a fun mental activity

  • @jgoon3
    @jgoon3 День назад

    because heapify should it be O(k log n + n)?

  • @LofiCoding11
    @LofiCoding11 День назад

    Nice Video Brother

  • @saraahmed408
    @saraahmed408 День назад

    Thank you so much for the explanation. But why the time complexity will be O(log n) if the tree was a balanced binary tree?

  • @aloha9938
    @aloha9938 День назад

    How am i getting TLE with this solution, it's the same thing class Solution: def checkRecord(self, n: int) -> int: pre = [[1,1,0], [1,0,0]] next = [[0]*3 for i in range(2)] for i in range(2,n+1): next[0][0] = pre[0][0] + pre[0][1] + pre[0][2] next[0][1] = pre[0][0] next[0][2] = pre[0][1] next[1][0] = pre[0][0] + pre[0][1] + pre[0][2] + pre[1][0] + pre[1][1] + pre[1][2] next[1][1] = pre[1][0] next[1][2] = pre[1][1] pre = next next = [[0]*3 for i in range(2)] res = 0 for l in pre: res += sum(l) % (10**9 + 7) return res % (10**9 + 7)

  • @romzeek
    @romzeek День назад

    bro discovered learning

  • @varunkedia6729
    @varunkedia6729 День назад

    can this be solved in the knapsack 0/1 way?

  • @abhinavkumar4375
    @abhinavkumar4375 День назад

    Speechless superb approach thank you so much

  • @eray3993
    @eray3993 День назад

    leetcode style questions is not a good measure of a good engineer. its just measuring if you prepared for those questions or not. i got a computer science degree and even for some specific use cases for these algorithms, a good engineer only should be familiar with the concepts and everyone can just google the details and implement the best solutions in daily job, but those interviews just expecting to write most efficient codes in a short amount time. because if you dont, somebody else will and they will be hired. so leetcode style interviews only measure how good you prepared for interviews not how good engineer you are. even the best engineers around cannot solve that kind of questions without preparing. they are not riddles or iq tests.

  • @michaelyao9389
    @michaelyao9389 День назад

    Can we just use a two-demension array for python solution?

  • @atg878
    @atg878 День назад

    why hash set is failed here?

  • @ventacode
    @ventacode День назад

    thanks bud, appreciate it !

  • @user-td4xo3be8b
    @user-td4xo3be8b День назад

    The explanation for this solution is amazing!

  • @bhargavinaik8145
    @bhargavinaik8145 День назад

    Not sure why it was only me who thought it could be a DP problem.

    • @MaheshKumar-mh9mj
      @MaheshKumar-mh9mj День назад

      same

    • @bhargavinaik8145
      @bhargavinaik8145 День назад

      @@MaheshKumar-mh9mj I went through some comments in the leetcode for this question, could come up with these reasonings, hope it helps. 1. The constraint is too high. 2. The local max will effect the global max so checking all possible choices is not needed. 3. The w is not reducing after picking any project. So if there was a project that we could have picked previously we will still be able to pick that project after finishing some other project. So we dont have to backtrack and check what would have happened for the next input if I dint do what I did earlier.

  • @arijaa.9315
    @arijaa.9315 День назад

    I can not understand you from the first time theeplanation some times is s stochastic, but I return to your videos always.

  • @LUN-bo2fb
    @LUN-bo2fb День назад

    c programming you are not really using a lot of external deps. X We still use libraries, but we know what's the complexity of adding deps. C and C++ developer are usually more aware of deps. And usually c library developer maintains interface compability better than web-dev's. And you are more likely to stuck at compile time and found interface mismatch easier and earlier.

  • @MP-ny3ep
    @MP-ny3ep День назад

    Great explanation!

  • @bst-vf5su
    @bst-vf5su День назад

    anyone not understanding this solution? Any other recommendations?

  • @NehaSingh29263
    @NehaSingh29263 День назад

    thankyou so much it helps me alot

  • @cryptocsguy9282
    @cryptocsguy9282 День назад

    I got recommenced to buy cracking the coding interview on codecademy

  • @data_dreamer
    @data_dreamer 2 дня назад

    crying at 8:30 haha

  • @sillymesilly
    @sillymesilly 2 дня назад

    Web dev with C.

  • @gokuanisantiogan
    @gokuanisantiogan 2 дня назад

    Why do we have to iterate n+max times? Can't we just iterate until the max number? Knowing that there's no more elements bigger than this one we can just calculate the triangle number of the remaining duplicates on one operation. Something like this: class Solution: def minIncrementForUnique(self, nums: List[int]) -> int: count = Counter(nums) res = 0 for i in range(max(nums)): if count[i] > 1: extra = count[i] - 1 count[i + 1] += extra res += extra n = count[max(nums)]-1 res+= n * (n +1)/2 return res

  • @user-rv1bx8hx4v
    @user-rv1bx8hx4v 2 дня назад

  • @stephan24297
    @stephan24297 2 дня назад

    It takes a lot of skill to not only conjur the idea but to bring it into code. I thought of the second solution as in how to fill in the gap but was stuck on how to iterate from key to key in a map.

    • @Vancha112
      @Vancha112 2 дня назад

      I came up with the second solution when my naive solution timed out. I managed to finally pass the time constraint, but looking at the code in the video i see that i solved a buch of problems with my code very inefficiently: Neetcode: 8 lines of code Me: me 28 lines of code -.- Same basic algorithm

  • @kavyanshpandey3823
    @kavyanshpandey3823 2 дня назад

    1. Sort both array. 2. Add abs different of same index value.

  • @kavyanshpandey3823
    @kavyanshpandey3823 2 дня назад

    Following you since last 4 month with 95 percent consistency

  • @ianwohlhieter9604
    @ianwohlhieter9604 2 дня назад

    ... and they hated him because he told the truth. ... and, when you understand the algorithm, you'll never need to memorize it, just translate your thought process into the context of the problem.

  • @vijethkashyap151
    @vijethkashyap151 2 дня назад

    BEST EVER!!!!!!!!!!!!!!!!

  • @hemiilisreal
    @hemiilisreal 2 дня назад

    how do u know all of this

  • @pat777b
    @pat777b 2 дня назад

    To get an O(n) solution, you can also do count sort instead of python's built in sort method in your first solution. Imo, this is easier to understand than your second solution even if it may take more lines of code. this is my python solution. class Solution: def minIncrementForUnique(self, nums: List[int]) -> int: large = max(nums) small = min(nums) counts = Counter(nums) nums = [] for i in range(small, large +1): for j in range(counts[i]): nums.append(i) ans = 0 minimum = nums[0] for i in range(len(nums)): if nums[i] < minimum: ans += minimum - nums[i] minimum += 1 else: minimum = nums[i] + 1 return ans

    • @turskaah
      @turskaah 2 дня назад

      using a counter makes the complexity O(n log n) though

    • @pat777b
      @pat777b День назад

      @@turskaah what, neetcode also uses a counter in his O(n) solution.

  • @mikehan47
    @mikehan47 2 дня назад

    So clear thx bro

  • @AhmedAmer-se1mr
    @AhmedAmer-se1mr 2 дня назад

    I came with the optimal solution easily, but I still must watch your videos

  • @swastiktiwari7066
    @swastiktiwari7066 2 дня назад

    In second solution : range(min(nums),max(nums)+len(nums)) instead of range(0,max(nums)+len(nums)).....min and max can be calculated simultaneously in single pass first

  • @and_then_I_whispered
    @and_then_I_whispered 2 дня назад

    Bro, do you ever get outside? Cause I see you always talking about Algorithms.

  • @tranminhquang4541
    @tranminhquang4541 2 дня назад

    I did DP for this !

  • @nirmalgurjar8181
    @nirmalgurjar8181 2 дня назад

    Only catch of this problem is how you prove if value at i is less than value i - 1 means there was a duplicate.

  • @ajayprabhu465
    @ajayprabhu465 2 дня назад

    did both by myself 🤧🤧

  • @saki-ch3rt
    @saki-ch3rt 2 дня назад

    You can just iterate to the max(nums) Let carry = count[max(nums)] if carry > 1, then add carry*(carry -1)/2 to the result Here is my C++ solution class Solution { public: int minIncrementForUnique(vector<int>& nums) { vector<int> counter(1e5 + 1); for (const auto& x : nums) { ++counter[x]; } int carry = 0; int res = 0; for (int x = 0; x < counter.size(); ++x) { counter[x] += carry; carry = max(counter[x] - 1, 0); res += carry; } res += max(carry - 1, 0) * carry / 2; return res; } };

  • @dmitriytereshchenko2032
    @dmitriytereshchenko2032 2 дня назад

    if we take the first solution, but use radix sort, will the solution improve to O(n + d), where n - length array, d - max number