Hey Neet, I just got placed in a company through the on-campus drive and want to thank you for your videos and the roadmap you created. There are quite a few teachers who use Python for LeetCoding but I found out that your explanations really helped me understand the concepts deeply and was able to give the interviews with confidence🙏
Hey man, I don't know if you did this but could you upload a video that you solve a segment tree problem. That way, you could teach us basics and usage of segment tree like you did for union find in the past. Thanks 🎉
For the second solution, can you add a 0 to the end of arr so if we go out of bounds we would index the last element which is 0. Very specific to python but similar thought to adding a 0 at the front.
a simpler way to optimize this code is for left, right in queries: if left == 0: ans.append(prefix[right]) else: ans.append(prefix[right]^prefix[left-1]) # in ur case maybe do prefix[right+1]^prefix[left] , if u have len(prefix) =len(arr)+1 -this also gives runtime 300 ms Complete solution - class Solution: def xorQueries(self, arr: List[int], queries: List[List[int]]) -> List[int]: l = len(arr) ans =[] prefix = [0]*l prefix[0] = arr[0] for i in range(1,l): prefix[i] = prefix[i-1] ^ arr[i] for left, right in queries: if left == 0: ans.append(prefix[right]) else: ans.append(prefix[right]^prefix[left-1]) return ans
for i in range(1,len(arr)): arr[i] = arr[i-1]^arr[i] res = [] for query in queries: left,right = query[0],query[1] if left == 0: res.append(arr[right]) else: res.append(arr[right]^arr[left-1]) return res
I thought the time complexity would be O(n * m) since we are going through each query and also the input arr for the calculations. Can anyone please clarify?
Hey Neet, I just got placed in a company through the on-campus drive and want to thank you for your videos and the roadmap you created. There are quite a few teachers who use Python for LeetCoding but I found out that your explanations really helped me understand the concepts deeply and was able to give the interviews with confidence🙏
LFG!!! congratulations you earned it my man
@@NeetCodeIO Thanks a lot man😄
Can please share your resume or suggest some projects @@NeetCodeIO
Congratulations man. Could u give us some suggestions about interview ? Like are they same or a bit different from the old videos ?
What college ?
Solved it on my own. Huge credit goes to your teaching style. Thanks man.
Bro, I Liked so much the style of having multiple solutions . It is useful to learn mutiple techniques.
Hey man, I don't know if you did this but could you upload a video that you solve a segment tree problem. That way, you could teach us basics and usage of segment tree like you did for union find in the past. Thanks 🎉
For the second solution, can you add a 0 to the end of arr so if we go out of bounds we would index the last element which is 0. Very specific to python but similar thought to adding a 0 at the front.
Great explanation as always. Thank you for doing the daily problems
a simpler way to optimize this code is
for left, right in queries:
if left == 0:
ans.append(prefix[right])
else:
ans.append(prefix[right]^prefix[left-1])
# in ur case maybe do prefix[right+1]^prefix[left] , if u have len(prefix) =len(arr)+1
-this also gives runtime 300 ms
Complete solution -
class Solution:
def xorQueries(self, arr: List[int], queries: List[List[int]]) -> List[int]:
l = len(arr)
ans =[]
prefix = [0]*l
prefix[0] = arr[0]
for i in range(1,l):
prefix[i] = prefix[i-1] ^ arr[i]
for left, right in queries:
if left == 0:
ans.append(prefix[right])
else:
ans.append(prefix[right]^prefix[left-1])
return ans
Thank you for providing. What math topics does one need be familiar with for DSA?
for i in range(1,len(arr)):
arr[i] = arr[i-1]^arr[i]
res = []
for query in queries:
left,right = query[0],query[1]
if left == 0:
res.append(arr[right])
else:
res.append(arr[right]^arr[left-1])
return res
You don't need extra space. Just store the prefix xor value in the original array.
Isn't that what I did?
@@NeetCodeIO Nevermind, I commented before watching the second approach.
I thought the time complexity would be O(n * m) since we are going through each query and also the input arr for the calculations.
Can anyone please clarify?
thank you neetcode
Hey, neet Code please suggest some advance projects
Hii bro please make video on open Ai o1
second