6289.Query array Xor Beautiful value。
This question has been studied for a long time,Discovering a mathematical problem,But I didn’t want to be transparent,Because unfamiliar or valuable。So there is no better solution。
The first is to read the question and learn(nums[i]|nums[j])&nums[k],becauseijkCan be any value in the array,So the tripleforcycle(It will definitely timeout),Then he was a little bit out of his own,Just a little bit,feeli,jThe value of the value is the same,So add an additional layer of judgment(Dictionary)。
1 | class Solution: |
I have been thinking about how to judge the same situation when I go out today,As a result@Lingcha Mountain AifuSolution,One by one,That’s okay。
1 | class Solution: |
Then do,Search online,It turns out that if the two values are the same,for exampleA^B^A = B,Soappend,removeTo implement this function。at lastforcycle求异或值。
Big Big Code is still studyinging