![NeetCodeIO](/img/default-banner.jpg)
- Видео 412
- Просмотров 9 345 779
NeetCodeIO
Добавлен 6 ноя 2022
Minimum Number of K Consecutive Bit Flips - Leetcode 995 - 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-number-of-k-consecutive-bit-flips/description/
0:00 - Read the problem
0:30 - Drawing Explanation 1
9:18 - Coding Explanation 1
12:13 - Drawing Explanation 2
16:09 - Coding Explanation 2
leetcode 995
#neetcode #leetcode #python
🧑💼 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-k-consecutive-bit-flips/description/
0:00 - Read the problem
0:30 - Drawing Explanation 1
9:18 - Coding Explanation 1
12:13 - Drawing Explanation 2
16:09 - Coding Explanation 2
leetcode 995
#neetcode #leetcode #python
Просмотров: 10 537
Видео
Longest Continuous Subarray with Absolute Diff Less than or Equal to Limit - Leetcode 1438 - Python
Просмотров 6 тыс.4 часа назад
🚀 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-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/ 0:00 - Read the problem 3:09 - Drawing Explanation 10:29 - Coding Ex...
Count Number of Nice Subarrays - Leetcode 1248 - Python
Просмотров 10 тыс.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/count-number-of-nice-subarrays/ 0:00 - Read the problem 0:30 - Drawing Explanation 7:46 - Coding Explanation leetcode 1248 #neetcode #leetcode #...
Grumpy Bookstore Owner - Leetcode 1052 - Python
Просмотров 9 тыс.12 часов назад
🚀 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/grumpy-bookstore-owner/description/ 0:00 - Read the problem 0:30 - Drawing Explanation 4:40 - Coding Explanation leetcode 1052 #neetcode #leetco...
Sum of Square Numbers - Leetcode 633 - Python
Просмотров 11 тыс.21 час назад
🚀 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/sum-of-square-numbers/description/ 0:00 - Read the problem 0:30 - Drawing Explanation 5:25 - Coding Explanation 7:54 - Drawing Explanation 2 13:...
Minimum Increment to Make Array Unique - Leetcode 945 - Python
Просмотров 13 тыс.День назад
🚀 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 ...
Minimum Number of Moves to Seat Everyone - Leetcode 2037 - 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/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 тыс.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/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 тыс.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/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
Просмотров 12 тыс.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/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
Просмотров 11 тыс.21 день назад
🚀 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
Просмотров 10 тыс.21 день назад
🚀 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 тыс.21 день назад
Append Characters to Strings to Make Subsequence - Leetcode 2486 - Python
Score of a String - Leetcode 3110 - Python
Просмотров 7 тыс.21 день назад
Score of a String - Leetcode 3110 - Python
Single Number III - Leetcode 260 - Python
Просмотров 9 тыс.21 день назад
Single Number III - Leetcode 260 - Python
Count Triplets That Can Form Two Arrays of Equal XOR - Leetcode 1442 - Python
Просмотров 8 тыс.21 день назад
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 тыс.28 дней назад
Number of Steps to Reduce a Number in Binary Representation to One - Leetcode 1404 - Python
Get Equal Substrings Within Budget - Leetcode 1208 - Python
Просмотров 7 тыс.28 дней назад
Get Equal Substrings Within Budget - Leetcode 1208 - Python
Special Array with X Elements Greater than or Equal X - Leetcode 1608 - Python
Просмотров 9 тыс.28 дней назад
Special Array with X Elements Greater than or Equal X - Leetcode 1608 - Python
How I would learn Leetcode if I could start over
Просмотров 262 тыс.28 дней назад
How I would learn Leetcode if I could start over
Student Attendance Record II - Leetcode 552 - Python
Просмотров 8 тыс.Месяц назад
Student Attendance Record II - Leetcode 552 - Python
Word Break II - Leetcode 140 - Python
Просмотров 10 тыс.Месяц назад
Word Break II - Leetcode 140 - Python
Maximum Score Words Formed By Letters - Leetcode 1255 - Python
Просмотров 9 тыс.Месяц назад
Maximum Score Words Formed By Letters - Leetcode 1255 - Python
The Number of Beautiful Subsets - Leetcode 2597 - Python
Просмотров 10 тыс.Месяц назад
The Number of Beautiful Subsets - Leetcode 2597 - Python
Sum of All Subsets XOR Total - Leetcode 1863 - Python
Просмотров 9 тыс.Месяц назад
Sum of All Subsets XOR Total - Leetcode 1863 - Python
Find the Maximum Sum of Node Values - Leetcode 3068 - Python
Просмотров 13 тыс.Месяц назад
Find the Maximum Sum of Node Values - Leetcode 3068 - Python
Distribute Coins in Binary Tree - Leetcode 979 - Python
Просмотров 15 тыс.Месяц назад
Distribute Coins in Binary Tree - Leetcode 979 - Python
Delete Leaves With a Given Value - Leetcode 1325 - Python
Просмотров 6 тыс.Месяц назад
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
Просмотров 12 тыс.Месяц назад
Find the Safest Path in a Grid - Leetcode 2812 - Python
Leetcode fucked me pretty hard.
PLZ LEETCODE 2090
Bro syaing LC isnt easy, come to codeforces bruh
their brains are simply wired differently than ours
Crazy I also had an interview with Veeva a couple of months ago but got a rejection email after I sent my availability for scheduling the 3rd round like what🤣
fantastic, at this poit it is more art then code
I suggest to use dict instead of lists when construction the graph (beats 95%) def maxProbability(self, n: int, edges: List[List[int]], succProb: List[float], start_node: int, end_node: int) -> float: res = 0 graph = collections.defaultdict(dict) # constructing a graph for (source, dest), prob in zip(edges, succProb): graph[source][dest] = prob graph[dest][source] = prob heap = [] heapq.heapify(heap) heapq.heappush(heap, (1, start_node)) visited = set() while heap: node_prob, node = heapq.heappop(heap) if node == end_node: return abs(node_prob) visited.add(node) for child in graph[node]: if child not in visited: heapq.heappush(heap, (-abs(node_prob) * graph[node][child] ,child)) return 0
I feel this video is an exception to your usual easy to understand explanations. I think it would be more concise to explain that the left and right most number would have a common prefix. The problem reduces to finding that common prefix (if any) between the left and right numbers of length 32 (and put zeros to the remaining positions), giving O(1) time complexity.
Thanks BRO
Old programming vet here - Finding implementation details in OOP can have developers feeling like a squirrel who hid so many nuts in different locations and then driving itself crazy when it can't find where it put those damn nuts! The crazy mind map of large OOP projects is not sustainable and gets worse as the project grows. They're also notoriously difficult to refactor because of the scattered dependency graphs and state. OOP structure essentially becomes code bureaucracy. Apart from this there looms an even larger problem, that OOP is a filing cabinet with a really contrived communication system (i.e. public/private/protected/internal). It totally misses the mark on implementation considerations on communicating and mutating data which detrimentally impacts the purpose of ANY language - expression! A guy named Brian Will (who read those thicker than Wrox Press programming bibles) demonstrated side-by-side practical implementations of OOP vs function based programming to accomplish the same things 8 years ago: ruclips.net/video/IRTfhkiAqPw/видео.htmlsi=kn58SMGIJAcxtb0X. The absurdity of OOP was laid bare. Many people came out to defend OOP and said it's good when you know how to implement it "properly". Yeah .... the problem is that it's too easy to do it wildly wrong and just because there's a whole industry making it work doesn't mean we took the right direction in history. People saying this have OOP Stockholm Syndrome. Alan Kay must have been so disappointed in the C++ to Java/C# progression. It was like a wrong turn the industry took 40+ years ago that we just started turning around from when functional programming began trending about a decade ago. He was too early for twitter and social media in general but #NoNotLikeThat && #ThatsNotWhatIMeant <<< Alan Kay (probably)
The best 🌟
Hi Neetcode, I’ve been focused on learning algorithms and patterns for about a year now, and normally when I see questions I could usually figure out what pattern or algorithm to use. So my question is how do I get good at solving these kind of questions cause they don’t follow the popular algorithms or patterns
did my own, by watching your video on surrounded region(dfs) thank you
based ublock user
Bottom-line, get good at core algorithms.
Me: is that a video that teaches how to learn? He: now, it only shows that you have to learn to be good at things Me: thanks for wasting my time
That's really the root cause of my problem. I have absolutely no problem doing the repetition. Even today, I can write down the BinarySearch, BFS, DFS algorithms straight from my mind. It's there. But I haven't really understood the WHY part yet. This leads to me not able to figure out which algorithm suits where, and why? How do you decide what algorithm to use here? And the same example you gave, how do you decide whether to use less than or lessthanOrEqualTo. Hoping I will figure this out soon enough. Thank you for this video.,
To everyone asking *how* to arrive at the intuition of greedily trying to flip any "0" bits, this was basically my thought process that led me there: 1. Since a flipping operation is reversible, that must mean that if I can go from "nums" to all 1s with flips, it must also be possible to go from all 1s to "nums". 2. If we ASSUME the array starts off as being all 1s, that would mean that the first bit that is 0 would HAVE to be the boundry of a flipping location. Since, those all 1's aren't going to sponaneously go from their initial state of "1" to "0" unless it is the start of a flip. 3. This assumption can pretty much apply recursively, where we can assume that any unexpected transition from "1" to "0" represents another flip. 4. If we reach the end and there are still flips not accounted for, that means there were flip boundaries at intervals other than "k" and that we didn't start with all 1s to begin with.
i know you made it pretty simple, but coming up with this logic of mod is basically made me go into existential crisis and question my reality
I understand how the solution works. I just don't understand why the greedy approach is the best solution here. How can a person who sees this problem guarantee that the greedy approach is the best way to go?
solution in java class Solution { public int minKBitFlips(int[] nums,int k){ Queue<Integer> q = new LinkedList<>(); int i = 0; int n = nums.length; int oprs = 0; while( i < n){ if( i > ( n - k) ){ if( (nums[i] + q.size()%2)%2 == 0 ) return -1; } else { if( (nums[i] + q.size()%2)%2 == 0 ){ oprs++; q.add(i); } } if( !q.isEmpty() && q.peek() == (i - k + 1) ){ q.poll(); } i++; } return oprs; } }
holy cow as soon as i understood how to use queue i solved it instantly on my own. Thanks man.
At this point, idk who reacts to who 😢
❤
awesome, u changed this Ques from Hard to Easy, this is why LeetCode ques in interview seem unfair sometimes, if u know u know
Solved it but with O(k) space! Sadly, unable to solve it using O(1) space!
Everything is nice nav. but one suggestion, while u provide the code, can u give a side-by-side animation on what is happening in the list or the code that runs..that would be really helpful.thank you
that's kinda your job with every code that you don't understand
Nice explanation!!
best explanation
Very beautiful
So, practicing and gaining experience from practice is the key?
Solved it on my own Beats(94%). Finally seeing the fruit of almost year of practise. class Solution: def minKBitFlips(self, nums: List[int], k: int) -> int: n = len(nums) flips = [0]*n flipSum = 0 count = 0 # Count the number of flips efficiently for i in range(n - k + 1): if (nums[i] == 0 and (flipSum == 0 or flipSum % 2 == 0)) or (nums[i] == 1 and flipSum % 2 == 1): count += 1 flips[i] = 1 flipSum += 1 if i + 1 >= k: flipSum -= flips[i - k + 1] # Check if last k character is 1 for i in range(n - k + 1, n): if (nums[i] == 0 and (flipSum == 0 or flipSum % 2 == 0)) or (nums[i] == 1 and flipSum % 2 == 1): return -1 flipSum -= flips[i - k + 1] return count
Waaoooo great explanation, is this a pattern? i haven't done any bit manipulation questions, though I knew I can use sliding window here but still just didn't know how....
Application complexity is not at the low level. Yes, you can make it complex (pls dont) but the major troubling issues are in the requirements which shift all the time. Modules, AI and - thinking it out for yourself, plus using descriptive variable names - get these trivial problems. Now amend and test a code base of 100,000 lines and Leet is seen as ho-hum.
remember: if your love makes you weak its not love . love only makes your partner stronger and as you
If you not understand go with AryanMittal explanation video it's fare better. He also a POTD creator
using multiset is alot easier but time is nlogn
Very Great Explanation. Thank you so much !!!
This is a great channel on Python. There is one channel "techie talkee" which explains all the important features and concepts in Python - SciPy , Matplotlib, Pandas , Data Science very clearly with excellent examples. It will be very useful to watch.
Why did you create multiple channels? Why are you no longer uploading video in your old channel?
This channel only focus on Leetcode POTD. 1st channel for Interview Preparation related stuff not solving ranom coding question
You are awesome
wowww this is 100 percent true and literally no one has said this truth or to be precise no one has ever put up words soo clearly in perspective you are insanee as said earlier!!!!!!!!!!!! you are the GOD Father!!!
Why use while? you can simply use if statement to pop the left element.
what if the queue had 2 flips that affected the last element ? we have to pop all the flips that no longer affect our current element , thats why we use while
@@aadityatripathi8363 you're checking at each iteration of i though so an if statement would be enough. Once an index is out of range it will immediately be removed from the queue in the next iteration
Yo neetcode I love your shorts you should add subtitles and labels to your thunbnails so you can get more views and reach a larger audience!
This problem is hell as hard.
Really nice solution
😢
I like the thumbnail have flipflops, lol.
First try with brute force and get TLE :D
Same bro tle on test case 101/113
110/113 :'D
I'm inexperienced with monotonic queues and used a multiset/heap - passed, but was very slow.