You are the best coding channel...my addiction with coding is only due to you
@heenakhan295
Жыл бұрын
I used to hate leetcode it have always been difficult for me to understand question of Leetcode, But since I came across your content It became easy for me to understand questions and approaches even though I code in java I always turn to your channel when I get stuck on a problem . Thank you so much ❤❤❤❤
@aishwariyaaish8305
Жыл бұрын
2 videos in less than 24 hrs. great dedication even during weekend, Hats off !! and much to learn from you apart from coding
@juderoosevelt2817
Ай бұрын
class Solution(object): def containsNearbyDuplicate(self, nums, k): for i in range (len(nums)): for j in range (i): if(nums[i]==nums[j] and abs(i-j)
@harishms5330
26 күн бұрын
O(n^2)
@immortalphoenix8886
9 ай бұрын
Very good approach learned so much from this video
@user-fk1zp5gk1o
Ай бұрын
another thing to note here is that we are using a "set" becuase we can check the existance of values i.e if value in window in O(1) as oppossed to a list where we would have to do it in O(n) time the other property of set which stores only unique values isn't really used here so that's a note-worthy point.
@officialaalamjotsingh9465
8 ай бұрын
this is my aproach to the problem def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool: num_dict = {} for i, num in enumerate(nums): if num in num_dict and i - num_dict[num]
@Tech-sl2hp
Ай бұрын
HI Neet, please look into contains duplicate III. I'd love to see your walkthrough
@horizon6285
Жыл бұрын
can you list more techniques like SLIDING WINDOW with advantages for practicing
@servantofthelord8147
11 ай бұрын
Thank you sir.
@TrevoZnaniy
7 ай бұрын
we can even get rid of variable `L` and checking the first `if` to be `if R > k`
@stylisgames
Ай бұрын
Hmm I don't think so. R - L is the size of the window because L may be shifted to the right at any point. You can't calculate the size of the window without L.
@krateskim4169
Жыл бұрын
Thank you
@SLowe-xi3fq
7 ай бұрын
this screamed nested for loop for me and it worked but i need to work on big o and optimization lol i suck.
@binfos7434
Жыл бұрын
Maybe it's better to use hashmap? from typing import List class Solution: def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool: temp_hash = {} l = 0 temp_hash[nums[l]] = 1 for r, val in enumerate(nums[1:], start=1): if (r - l) > k: temp_hash[nums[l]] -= 1 l += 1 temp_hash[val] = temp_hash.get(val, 0) + 1 if temp_hash[val] > 1: return True else: return False
@sykarius01
9 ай бұрын
hashmap approach class Solution: def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool: hmap={} for i in range(len(nums)): if nums[i] in hmap: if abs(hmap[nums[i]]-i)
@juderoosevelt2817
Ай бұрын
I understood this better than the actual video 😭😭
@nikhilg251
Ай бұрын
class Solution(object): def containsNearbyDuplicate(self, nums, k): """ :type nums: List[int] :type k: int :rtype: bool """ dic = {} for ind,i in enumerate(nums): if i in dic and abs(ind-dic[i])
@sergiofranklin8809
Жыл бұрын
dict_ = {} for i, n in enumerate(nums): if n in dict_ and abs(i-dict_[n])
@kumarc4853
4 ай бұрын
nice, dont need the abs method, cuz the i is always going be to bigger than whatever is in the dict
@cosepeter2197
Жыл бұрын
Hi NEET can make a video on leetcode 2564. Substring XOR Queries?
@vidhushekhar8144
3 ай бұрын
nums = [1,0,1,1] in this case your solution is wrong
@maahasgharali571
Жыл бұрын
Why would the window size be k+1?
@user-le6ts6ci7h
Жыл бұрын
Optimised
@leeroymlg4692
Жыл бұрын
because k is not how many elements are in the window, but how far apart they are. So if you have k = 1, you need a window size of 2 because the 2 elements are 1 index apart.
@aishwariyaaish8305
Жыл бұрын
1263 Minimum Moves to Move a Box to Their Target Location could you pls help to solve this question.
@sankaranarayanankm7049
Жыл бұрын
but initially we are not adding any values to the window set so how does this is working ?? please help
@ChrisCox-wv7oo
10 ай бұрын
All values are added at line 12. You don't need to set an initial value for the set. The for loop will add the first element the first iteration.
@KishoreRE
5 ай бұрын
i am not able to understand this code logic can anyone explain
@visase2036
Жыл бұрын
Face reveallllllllllll anytime soon ????
@bossmusa9075
Жыл бұрын
i feel myself so dumb(
@kimashiidan
2 ай бұрын
i dont even know how tf would i ever come up with this code
@wantedunknowngaming0504
10 ай бұрын
I solved it but still got it wrong so I’m here once again feeling like a dummy
Пікірлер: 34