ans+=i-j-1; ans+=i; these always confuses me, in the xor 0 case , please explain taking the example of when we encounter another xor 0.... in that case it'll consider the length of the subarray from 0 index or from the last found 0 index?
@blah61086 ай бұрын
Are you a dynamic array? Because you're expanding my heart's capacity and I want to allocate more space for us. And even if we encounter an out-of-bounds error, I'm willing to resize our love to fit perfectly.
@atanukundu_106 ай бұрын
what😂😂😂😂
@paracetamol91166 ай бұрын
padh le bhai
@Rajadas0000005 ай бұрын
in map you are containing list of integer. so for every value in your list you are counting triplets. it's not a O(n) solution! Time complexity will be O(n^2).
@clickit15076 ай бұрын
"Are you a linked list? Because I feel connected to you in every possible way." "If I were an algorithm, I'd be greedy, because I just can't get enough of you." "Do you believe in depth-first search? Because I've been diving deep into my feelings for you." "Are you a red-black tree? Because you keep my life balanced and exciting." "Are you a priority queue? Because you always come first in my heart."
@blah61086 ай бұрын
Atleast mine are original 🙂
@clickit15076 ай бұрын
@@blah6108 but your love is fake;
@blah61086 ай бұрын
Never said true love.. these are only to make her day
@ashutoshpandey42716 ай бұрын
Hi, how to do if the question has mentioned i
@algorithmsbyaditi6 ай бұрын
If we look closely, we can have i=j and j=k in the current question. We don't have i=j=k currently, but this probably means we will have to consider all the length one subarrays along with pairs of subarrays who satisfy our xor based condition. In that case, we will add length of our array to the final ans which already contains no. of pairs of subarrays satisfying the xor based condition
@pushanmukhopadhyay33796 ай бұрын
can you explain 16,17,18 number lines?
@algorithmsbyaditi6 ай бұрын
These lines contain the logic to store prefix xor at every index. We retrieve the list of indexes at which current xor happened previously, if we don't have any such entry in the map, we create a new arraylist (this is what getOrDefault typically does). Next we add our current index in this list and finally store this list into the map with key as current xor value.
@SoumyaRanjanSahoo-kq4ez6 ай бұрын
Could you please tell me how to optimise it ?
@algorithmsbyaditi6 ай бұрын
It's already done in O(n) space and time complexity. Imo this is the best tc one can achieve.
@SoumyaRanjanSahoo-kq4ez6 ай бұрын
@@algorithmsbyaditi in leetcode it is solving in 4 ms. I was asking can we solve this in 0 ms or 1 ms ?
@algorithmsbyaditi6 ай бұрын
Leetcode runtime vary many times when we submit the code. Imo it is a pretty decent solution. kzbin.infoEPx-ZDciIpc?si=cnPqTM0m9DandiZN