For each problems, please click on the companies tab and show us the companies
@Alpha-CodeКүн бұрын
@@udhaya8489 sure I’ll do that
@vikasg5816Күн бұрын
Clear explanation. Thanks
@storingudemy-yg7xs2 күн бұрын
For some reason my test case isn't passing when i try to submit
@rajan-u6b2 күн бұрын
I was stuck for very long time, then eventually figure out the 'Long', lol
@snehalsrivastava28102 күн бұрын
I was also stuck at the problem where you converted int into long for 30 minutes thankyou
@shreyabajaj45884 күн бұрын
Why didn't u put the sols of weekly contest 405 solution and biweekly contest sols😢
@Alpha-Code4 күн бұрын
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.
@MishkatMazumder4 күн бұрын
Best explanation of this problem I have seen so far, many thanks.
@juanmacias59225 күн бұрын
I assumed I was missing a constant time math proof, but I guess simulation is the only way ha
@Alpha-Code5 күн бұрын
There is I think but it's not super intuitive :(
@juanmacias59225 күн бұрын
@@Alpha-Code that makes sense. ha thanks for the video. :D
@rajan-u6b6 күн бұрын
this kind of question is quite frequent in LC contest, I just use flag variable for direction and simulate
@jantrollan33586 күн бұрын
Very good explanation
@GelfandTransform11 күн бұрын
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-u6b12 күн бұрын
only able to solve first 2. thanks for your editorials
@AryanSingh-eq2jv16 күн бұрын
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-eq2jv16 күн бұрын
it works but gives me a TLE so ig it doesnt really work
@AryanSingh-eq2jv16 күн бұрын
really appreciate it man
@danishtiwari252017 күн бұрын
Great Video and explanation thanks a bunch!!
@margin100px18 күн бұрын
Cool thumbnail!!
@rajan-u6b19 күн бұрын
please don't say problems were that easy😑, love your videos btw, solution for W-403 coming?
@Alpha-Code19 күн бұрын
yup uploading now. Hehe sorry.
@rajan-u6b19 күн бұрын
thanks
@rashidmahmood712119 күн бұрын
Great explanation. Is there any way we can connect? LinkedIn?
@Alpha-Code19 күн бұрын
Yeah sure I'll add my LinkedIn to the about page.
@rashidmahmood712120 күн бұрын
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.
@Leetneetcode172920 күн бұрын
i do not understand
@Alpha-Code20 күн бұрын
:) Lemme know what in particular.
@rostyslavmochulskyi15921 күн бұрын
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-Code21 күн бұрын
Gotcha, I think in Python its also not O(1) for sort but most people write it that way.
@MehdiKhfifi21 күн бұрын
i don't understand why the left position has to be 1 and not 0?
@tzuilee58821 күн бұрын
it doesn't matter if it's 0 or 1, we are binary searching the gap not the array index
@Alpha-Code21 күн бұрын
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.
@mituldwivedi446923 күн бұрын
i got the time limit exceed through your code , please help me!!
@Alpha-Code23 күн бұрын
which one the Java code? They all seem to be working for me so I think it's an issue on your end.
@mituldwivedi446923 күн бұрын
@@Alpha-Code my bad I interchanged the left and right pointers 🥲🥲
@juanmacias592223 күн бұрын
@@Alpha-Code personally I messed up by incrementing/decrementing by one, and not by the middle + or - 1 lol
@sunshinekanika579723 күн бұрын
would sliding windows make it concise or possible that way?
@Alpha-Code23 күн бұрын
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.
@shreyabajaj458824 күн бұрын
Great logic!!
@Alpha-Code24 күн бұрын
Thanks!
@kevinnguyen422225 күн бұрын
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 😆
@tzuilee58825 күн бұрын
well explained, thanks man!
@udhaya848926 күн бұрын
I was expecting your video Yesterday
@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Ай бұрын
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Ай бұрын
Beautiful explanation! Thank you very much
@saranshthukral4021Ай бұрын
killin it with the streak man..🍏🍏
@kevinnguyen4222Ай бұрын
Solid solid content man - thank you!
@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Ай бұрын
Hi. Glad to hear it and best of luck at your new role.
@think_n_codeАй бұрын
Nice explanation Thanks
@juanmacias5922Ай бұрын
Man, I really need to study up on bit operations lol
@ShubhamSharma-sf8wkАй бұрын
For some reason the video quality is not going beyond 360p
@Alpha-CodeАй бұрын
There's 1440p now. Takes about an hour to go to HD
@GarimaMadaan-dw9mrАй бұрын
Very nice video,informative ,concept explained in a very simple way. keep it up
@klnlkjoinoinАй бұрын
great solution, and I learned that python heappush sorts array entries lexicographically
@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Ай бұрын
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Ай бұрын
Thank U great job👍
@manne4795Ай бұрын
Great explanation
@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Ай бұрын
In the video you were saying about backtracking template , would you mind sharing that?
@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Ай бұрын
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Ай бұрын
thx, great work!
@andysmountainАй бұрын
Holy cow. Clever solution and more importantly great explanation!
@ShubhamSharma-sf8wkАй бұрын
Great explanation bro, just a small suggestion, get a nice mic. Your content is way too good.
@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!