updated with time complexity and sample input-output
parent
a05e2425be
commit
6eb43eda04
|
@ -1,3 +1,10 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
one of the standard Brute force is O(n^2),but this is optimized version of this question
|
||||||
|
time complexity of inserting all element in Trie of array is O(31*n).
|
||||||
|
time complexity of finding Xor of each element in Trie of given array is O(31*n).
|
||||||
|
so the complexity is O(31*n);
|
||||||
|
*/
|
||||||
#include <bits/stdc++.h>
|
#include <bits/stdc++.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
#define ll long long int
|
#define ll long long int
|
||||||
|
@ -142,4 +149,10 @@ int main()
|
||||||
mx = max(mx, res ^ i);
|
mx = max(mx, res ^ i);
|
||||||
}
|
}
|
||||||
cout << mx;
|
cout << mx;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
sample input
|
||||||
|
a = [1,2,3]
|
||||||
|
output
|
||||||
|
3 (i.e. (2^1))
|
||||||
|
*/
|
Loading…
Reference in New Issue