Search
⌘K

Leetcode 1803. Count Pairs With XOR in a Range

Count the number of index pairs (i<j) whose XOR falls within [low, high]; the challenge is to do better than O(n^2) by computing, for each element, how many previous elements produce XOR ≤ bound and using a binary trie (bitwise prefix tree) to get an O(n log C) solution (C = max value range).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.