@codingmohan I did a double for loop for all possible pairs of numbers in nums as stated in the question. Then, I used a checker function (x,y) which increments my answer by 1 if it's true. Now, what my checker function does is to initialize a disjoint set of size 7, iterates through the numbers while comparing them at each position. If they are different and don't belong to the same parent, then I united them E.g (4598, 5489) 4 and 5 is different and so I merge them 5 and 4 is different but they already belong to the same group 9 and 8 is different so I merge 8 and 9 is different but they are already merged so I skip I know the approach is buggy but I was wondering why disjoint set won't work
@@dawodujohnson amazing idea bro , how did you incremented your ans then, perhaps if you have to unite more than twice than it is not possible else possible and hence increase ans by 1 but the main caveat is handling leading zeroes
Great explanation
Perfect explanation by the way
very nice and clear explanation , thanks :)
leetcode weekly contest 411 ques D, can you discuss please
Well made video
Can we solve it using disjoint set?
Really tried hard but failed at 604/630
What was your approach?
@codingmohan I did a double for loop for all possible pairs of numbers in nums as stated in the question. Then, I used a checker function (x,y) which increments my answer by 1 if it's true.
Now, what my checker function does is to initialize a disjoint set of size 7, iterates through the numbers while comparing them at each position. If they are different and don't belong to the same parent, then I united them
E.g (4598, 5489)
4 and 5 is different and so I merge them
5 and 4 is different but they already belong to the same group
9 and 8 is different so I merge
8 and 9 is different but they are already merged so I skip
I know the approach is buggy but I was wondering why disjoint set won't work
@@dawodujohnson amazing idea bro , how did you incremented your ans then, perhaps if you have to unite more than twice than it is not possible else possible and hence increase ans by 1 but the main caveat is handling leading zeroes
First viewer🥰, but sir quality is upto 360p only
It takes some time for RUclips to process video in higher formats. It should be all good now.