This TRIE data structure offers the following functions:
-
insert(x,y)
- Inserts
y
occurrences of the integerx
. - Default value of
y
is 1.
- Inserts
-
erase(x,y)
- Erases
y
occurrences of the integerx
. - Default value of
y
is 1.
- Erases
-
count(x)
- Returns the number of occurrences of the integer
x
.
- Returns the number of occurrences of the integer
-
findSmallest(k)
- Returns the kth smallest integer.
- Default value of
k
is 1.
-
eraseSmallest(k)
- Erases the kth smallest integer.
- Default value of
k
is 1.
-
findGreatest(k)
- Returns the kth greatest integer.
- Default value of
k
is 1.
-
eraseGreatest(k)
- Erases the kth greatest integer.
- Default value of
k
is 1.
-
countSmaller(x, y)
- For
y = 0
: Returns the count of integers smaller thanx
. - For
y = 1
: Returns the count of integers smaller than or equal tox
. - Default value of
y
is 0.
- For
-
countGreater(x, y)
- For
y = 0
: Returns the count of integers greater thanx
. - For
y = 1
: Returns the count of integers greater than or equal tox
. - Default value of
y
is 0.
- For
-
minxor(x)
- Returns the minimum value of
x XOR y
wherey
is any integer present in the Trie.
- Returns the minimum value of
-
maxxor(x)
- Returns the maximum value of
x XOR y
wherey
is any integer present in the Trie.
- Returns the maximum value of
-
sorted()
- Returns a vector containing all integers present in the Trie in non decreasing order.