1442. Count Triplets That Can Form Two Arrays of Equal XOR | Leetcode POTD 30-05-2024 | Java | Hindi

  Рет қаралды 682

AlgorithmHQ

AlgorithmHQ

Күн бұрын

Пікірлер: 21
@SoumyaRanjanSahoo-kq4ez
@SoumyaRanjanSahoo-kq4ez 6 ай бұрын
Your explanation is gooood
@algorithmsbyaditi
@algorithmsbyaditi 6 ай бұрын
Glad it helped ! Thanks a lot.
@aizad786iqbal
@aizad786iqbal 5 ай бұрын
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?
@blah6108
@blah6108 6 ай бұрын
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_10
@atanukundu_10 6 ай бұрын
what😂😂😂😂
@paracetamol9116
@paracetamol9116 6 ай бұрын
padh le bhai
@Rajadas000000
@Rajadas000000 5 ай бұрын
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).
@clickit1507
@clickit1507 6 ай бұрын
"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."
@blah6108
@blah6108 6 ай бұрын
Atleast mine are original 🙂
@clickit1507
@clickit1507 6 ай бұрын
@@blah6108 but your love is fake;
@blah6108
@blah6108 6 ай бұрын
Never said true love.. these are only to make her day
@ashutoshpandey4271
@ashutoshpandey4271 6 ай бұрын
Hi, how to do if the question has mentioned i
@algorithmsbyaditi
@algorithmsbyaditi 6 ай бұрын
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
@pushanmukhopadhyay3379
@pushanmukhopadhyay3379 6 ай бұрын
can you explain 16,17,18 number lines?
@algorithmsbyaditi
@algorithmsbyaditi 6 ай бұрын
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-kq4ez
@SoumyaRanjanSahoo-kq4ez 6 ай бұрын
Could you please tell me how to optimise it ?
@algorithmsbyaditi
@algorithmsbyaditi 6 ай бұрын
It's already done in O(n) space and time complexity. Imo this is the best tc one can achieve.
@SoumyaRanjanSahoo-kq4ez
@SoumyaRanjanSahoo-kq4ez 6 ай бұрын
@@algorithmsbyaditi in leetcode it is solving in 4 ms. I was asking can we solve this in 0 ms or 1 ms ?
@algorithmsbyaditi
@algorithmsbyaditi 6 ай бұрын
Leetcode runtime vary many times when we submit the code. Imo it is a pretty decent solution. kzbin.infoEPx-ZDciIpc?si=cnPqTM0m9DandiZN
@dayashankarlakhotia4943
@dayashankarlakhotia4943 6 ай бұрын
Time and space?
@algorithmsbyaditi
@algorithmsbyaditi 6 ай бұрын
Time and space complexities are both O(n)
Yay😃 Let's make a Cute Handbag for me 👜 #diycrafts #shorts
00:33
LearnToon - Learn & Play
Рет қаралды 117 МЛН
Thank you Santa
00:13
Nadir Show
Рет қаралды 48 МЛН
What Is Abstraction in Computer Science
6:24
Codexpanse with Rakhim
Рет қаралды 97 М.
How I Mastered Data Structures and Algorithms in 8 Weeks
15:46
Aman Manazir
Рет қаралды 107 М.
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 743 М.
2 Years of C++ Programming
8:20
Zyger
Рет қаралды 10 М.
Imaginary numbers aren't imaginary
13:55
Ali the Dazzling
Рет қаралды 132 М.
What Do Software Engineers Actually Do? (It’s Not What You Think)
13:07