LeetCode 1598 - Crawler Log Folder - Java
7:22
LeetCode 1518 - Water Bottles - Java
8:08
12 сағат бұрын
LeetCode 2582 - Pass the Pillow - Java
7:23
LeetCode 330 - Patching Array - Java
17:13
Пікірлер
@udhaya8489
@udhaya8489 Күн бұрын
For each problems, please click on the companies tab and show us the companies
@Alpha-Code
@Alpha-Code Күн бұрын
@@udhaya8489 sure I’ll do that
@vikasg5816
@vikasg5816 Күн бұрын
Clear explanation. Thanks
@storingudemy-yg7xs
@storingudemy-yg7xs 2 күн бұрын
For some reason my test case isn't passing when i try to submit
@rajan-u6b
@rajan-u6b 2 күн бұрын
I was stuck for very long time, then eventually figure out the 'Long', lol
@snehalsrivastava2810
@snehalsrivastava2810 2 күн бұрын
I was also stuck at the problem where you converted int into long for 30 minutes thankyou
@shreyabajaj4588
@shreyabajaj4588 4 күн бұрын
Why didn't u put the sols of weekly contest 405 solution and biweekly contest sols😢
@Alpha-Code
@Alpha-Code 4 күн бұрын
I was busy with work stuff this week. Might put up weekly contest solution up later, it wasn't the best one. All the problems were pretty standard and the last one was just basically Word Break Problem with 2 more lines of code.
@MishkatMazumder
@MishkatMazumder 4 күн бұрын
Best explanation of this problem I have seen so far, many thanks.
@juanmacias5922
@juanmacias5922 5 күн бұрын
I assumed I was missing a constant time math proof, but I guess simulation is the only way ha
@Alpha-Code
@Alpha-Code 5 күн бұрын
There is I think but it's not super intuitive :(
@juanmacias5922
@juanmacias5922 5 күн бұрын
@@Alpha-Code that makes sense. ha thanks for the video. :D
@rajan-u6b
@rajan-u6b 6 күн бұрын
this kind of question is quite frequent in LC contest, I just use flag variable for direction and simulate
@jantrollan3358
@jantrollan3358 6 күн бұрын
Very good explanation
@GelfandTransform
@GelfandTransform 11 күн бұрын
Very nice explanation! And cool art in the thumb nail. I need to think about why, when generating a spanning tree, the method of first choosing type 3 edges when possible, and then secondarily choosing type 1 & 2 edges, always gives the maximal number of edges that can be removed.
@rajan-u6b
@rajan-u6b 12 күн бұрын
only able to solve first 2. thanks for your editorials
@AryanSingh-eq2jv
@AryanSingh-eq2jv 16 күн бұрын
i wrote this code class Solution: def modifiedGraphEdges(self, n: int, edges: List[List[int]], source: int, destination: int, target: int) -> List[List[int]]: graph = defaultdict(lambda:defaultdict(lambda:float("inf"))) for edge in edges: graph[edge[0]][edge[1]]=edge[2] graph[edge[1]][edge[0]]=edge[2] while(True): shortest={} minHeap=[] heapq.heappush(minHeap,(0,source)) while minHeap: cost,node = heapq.heappop(minHeap) if node in shortest: continue shortest[node]=cost for neighbour,cost_to_neighbour in graph[node].items(): if neighbour not in shortest: if cost_to_neighbour==-1: heapq.heappush(minHeap,(cost+1,neighbour)) else: heapq.heappush(minHeap,(cost+cost_to_neighbour,neighbour)) if shortest[destination]>target: return [] if shortest[destination]==target: for i in range(len(edges)): if edges[i][2]==-1: edges[i][2]=1 return edges l=[destination] pathh=[] def path(node,cost): nonlocal pathh if cost==0: pathh=l.copy() return for neighbour,cost_to_neighbour in graph[node].items(): if cost_to_neighbour==-1: cost_to_neighbour=1 if cost - cost_to_neighbour == shortest[neighbour]: l.append(neighbour) path(neighbour,cost-cost_to_neighbour) l.pop(-1) path(destination,shortest[destination]) flag=True pathh=pathh[::-1] a=10**9 b=10**9 for i in range(len(pathh)-1): if graph[pathh[i]][pathh[i+1]]==-1: a=pathh[i] b=pathh[i+1] flag=False break if flag: return [] for edge in edges: if (edge[0]==a and edge[1]==b) or (edge[1]==a and edge[0]==b): edge[2]=target-shortest[destination]+1 graph[edge[0]][edge[1]]=target-shortest[destination]+1 graph[edge[1]][edge[0]]=target-shortest[destination]+1 break
@AryanSingh-eq2jv
@AryanSingh-eq2jv 16 күн бұрын
it works but gives me a TLE so ig it doesnt really work
@AryanSingh-eq2jv
@AryanSingh-eq2jv 16 күн бұрын
really appreciate it man
@danishtiwari2520
@danishtiwari2520 17 күн бұрын
Great Video and explanation thanks a bunch!!
@margin100px
@margin100px 18 күн бұрын
Cool thumbnail!!
@rajan-u6b
@rajan-u6b 19 күн бұрын
please don't say problems were that easy😑, love your videos btw, solution for W-403 coming?
@Alpha-Code
@Alpha-Code 19 күн бұрын
yup uploading now. Hehe sorry.
@rajan-u6b
@rajan-u6b 19 күн бұрын
thanks
@rashidmahmood7121
@rashidmahmood7121 19 күн бұрын
Great explanation. Is there any way we can connect? LinkedIn?
@Alpha-Code
@Alpha-Code 19 күн бұрын
Yeah sure I'll add my LinkedIn to the about page.
@rashidmahmood7121
@rashidmahmood7121 20 күн бұрын
I'm a Java coder and I wasn't able to find any KZfaq channel where I could get solution explanations to daily leetcode problems which led me to breaking my streak many times. I was following a python guy but it was inconvenient to understand the python code and then write the same in java. Thanks to you that you upload videos everyday and now I'm able to solve problems easily.
@Leetneetcode1729
@Leetneetcode1729 20 күн бұрын
i do not understand
@Alpha-Code
@Alpha-Code 20 күн бұрын
:) Lemme know what in particular.
@rostyslavmochulskyi159
@rostyslavmochulskyi159 21 күн бұрын
In Java, Arrays.sort() is implemented using a variant of the Quick Sort algorithm which has a space complexity of O(logn) for sorting
@Alpha-Code
@Alpha-Code 21 күн бұрын
Gotcha, I think in Python its also not O(1) for sort but most people write it that way.
@MehdiKhfifi
@MehdiKhfifi 21 күн бұрын
i don't understand why the left position has to be 1 and not 0?
@tzuilee588
@tzuilee588 21 күн бұрын
it doesn't matter if it's 0 or 1, we are binary searching the gap not the array index
@Alpha-Code
@Alpha-Code 21 күн бұрын
It wouldn't matter, but also if you have enough buckets to put the balls in if it was zero you'd put every ball in the same bucket which wouldn't make sense. You can always put the balls in different buckets and the minimum space between buckets is 1.
@mituldwivedi4469
@mituldwivedi4469 23 күн бұрын
i got the time limit exceed through your code , please help me!!
@Alpha-Code
@Alpha-Code 23 күн бұрын
which one the Java code? They all seem to be working for me so I think it's an issue on your end.
@mituldwivedi4469
@mituldwivedi4469 23 күн бұрын
@@Alpha-Code my bad I interchanged the left and right pointers 🥲🥲
@juanmacias5922
@juanmacias5922 23 күн бұрын
@@Alpha-Code personally I messed up by incrementing/decrementing by one, and not by the middle + or - 1 lol
@sunshinekanika5797
@sunshinekanika5797 23 күн бұрын
would sliding windows make it concise or possible that way?
@Alpha-Code
@Alpha-Code 23 күн бұрын
I don't think you can do sliding windows cause you don't know the range of numbers you can have in the window is the issue. That's why bin search is better.
@shreyabajaj4588
@shreyabajaj4588 24 күн бұрын
Great logic!!
@Alpha-Code
@Alpha-Code 24 күн бұрын
Thanks!
@kevinnguyen4222
@kevinnguyen4222 25 күн бұрын
Great video! I knew the last one was a Segment Tree but couldn't figure it out directly. Very smart to pose it as a range sum question. Was missing your vid last week 😆
@tzuilee588
@tzuilee588 25 күн бұрын
well explained, thanks man!
@udhaya8489
@udhaya8489 26 күн бұрын
I was expecting your video Yesterday
@abhcode7219
@abhcode7219 Ай бұрын
How did you come up with this approach many people are using treemap/priority queue/min heap for it ,how to decide the good one? I personally loved this solution since it is straight forward! Thanks
@Alpha-Code
@Alpha-Code Ай бұрын
Well I realized that I need to know the min value available and can get the rest from there so yeah either min heap or just use hashmap and array since my values never change. Heap better for when your values change instead of static.
@Zmakinator
@Zmakinator Ай бұрын
Beautiful explanation! Thank you very much
@saranshthukral4021
@saranshthukral4021 Ай бұрын
killin it with the streak man..🍏🍏
@kevinnguyen4222
@kevinnguyen4222 Ай бұрын
Solid solid content man - thank you!
@chandansp27
@chandansp27 Ай бұрын
Hey! Writing this comment from India. I've been watching your content for almost 6 months now, and your videos helped me clear DSA rounds. I recently got an MLE role at a startup here. Thanks a lot for the great content!
@Alpha-Code
@Alpha-Code Ай бұрын
Hi. Glad to hear it and best of luck at your new role.
@think_n_code
@think_n_code Ай бұрын
Nice explanation Thanks
@juanmacias5922
@juanmacias5922 Ай бұрын
Man, I really need to study up on bit operations lol
@ShubhamSharma-sf8wk
@ShubhamSharma-sf8wk Ай бұрын
For some reason the video quality is not going beyond 360p
@Alpha-Code
@Alpha-Code Ай бұрын
There's 1440p now. Takes about an hour to go to HD
@GarimaMadaan-dw9mr
@GarimaMadaan-dw9mr Ай бұрын
Very nice video,informative ,concept explained in a very simple way. keep it up
@klnlkjoinoin
@klnlkjoinoin Ай бұрын
great solution, and I learned that python heappush sorts array entries lexicographically
@ShubhamSharma-sf8wk
@ShubhamSharma-sf8wk Ай бұрын
Why brute force solution is faster than the optimal one? Is it the sorting? Brute force(checking for each element) is faster than 100%
@Alpha-Code
@Alpha-Code Ай бұрын
would depend on test cases there. If you have 1k nums to check should be slower in theory. But with certain test cases it can be faster.
@jasonshane1323
@jasonshane1323 Ай бұрын
Thank U great job👍
@manne4795
@manne4795 Ай бұрын
Great explanation
@Alpha-Code
@Alpha-Code Ай бұрын
small error with counting from day 2 to 3 at 13:00. I skipped the value that had 1 absence and 0 late streak, so the results for day 3 were a bit off. But the logic should still be fine.
@mystic__ar
@mystic__ar Ай бұрын
In the video you were saying about backtracking template , would you mind sharing that?
@rostyslavmochulskyi159
@rostyslavmochulskyi159 Ай бұрын
O(2^n) solution: class Solution { int count = 0; public int beautifulSubsets(int[] nums, int k) { Arrays.sort(nums); backtrackSubSets(nums, k, new HashMap<>(), 0); return count; } private void backtrackSubSets(int[] nums, int k, Map<Integer, Integer> currentSubsetMap, int index) { if (index > nums.length - 1) { if (!currentSubsetMap.isEmpty()) { count++; } return; } if (!currentSubsetMap.containsKey(nums[index] - k)) { currentSubsetMap.put(nums[index], currentSubsetMap.getOrDefault(nums[index], 0) + 1); backtrackSubSets(nums, k, currentSubsetMap, index + 1); currentSubsetMap.put(nums[index], currentSubsetMap.get(nums[index]) - 1); if (currentSubsetMap.get(nums[index]) == 0) { currentSubsetMap.remove(nums[index]); } } backtrackSubSets(nums, k, currentSubsetMap, index + 1); } }
@rostyslavmochulskyi159
@rostyslavmochulskyi159 Ай бұрын
I wonder if this is enough to pass interview or it is required to do nlogn solution, which I wasn't able to come up with
@Dzhjmmybbbn
@Dzhjmmybbbn Ай бұрын
thx, great work!
@andysmountain
@andysmountain Ай бұрын
Holy cow. Clever solution and more importantly great explanation!
@ShubhamSharma-sf8wk
@ShubhamSharma-sf8wk Ай бұрын
Great explanation bro, just a small suggestion, get a nice mic. Your content is way too good.
@SecludedRain
@SecludedRain Ай бұрын
Hello, would you mind taking a look at LeetCode problem 128? I'm finding the time complexity and runtime behavior quite puzzling. Interestingly, O(n) seems to lag far behind O(n log n) in terms of speed. I would really appreciate it if you could shed some light on this matter!
@udhaya8489
@udhaya8489 Ай бұрын
Congrats on streak 300💥💥
@AbhijeetMuneshwar
@AbhijeetMuneshwar Ай бұрын
6:27 : It should be 2 instead of 3.
@Alpha-Code
@Alpha-Code Ай бұрын
Yeah that's true middle one should be two.