Skip to content

Commit be1bdf5

Browse files
committed
.
1 parent 58c443b commit be1bdf5

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

maximum-xor-of-two-numbers-in-an-array.cc

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
class Solution {
33
public:
44
int findMaximumXOR(vector<int>& nums) {
5-
int m = 0, r = 0;
5+
int r = 0;
66
unordered_set<int> s;
77
for (int i = 30; i >= 0; i--) {
8-
m |= 1<<i;
8+
int m = r | 1<<i;
99
s.clear();
1010
for (int x: nums)
1111
s.insert(x & m);
12-
int t = r|1<<i;
1312
for (int x: s)
14-
if (s.count(x^t)) {
15-
r = t;
13+
if (s.count(x^m)) {
14+
r = m;
1615
break;
1716
}
1817
}

merge-bsts-to-create-single-bst.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Solution {
2525
if (TreeNode *y = x->left) {
2626
while (y->right && y->right != x)
2727
y = y->right;
28-
if (y->right != x) {
28+
if (!y->right) {
2929
y->right = x;
3030
x = x->left;
3131
continue;

0 commit comments

Comments
 (0)