当前位置:网站首页>Not for 63 days. The biggest XOR
Not for 63 days. The biggest XOR
2022-07-29 04:16:00 【A little Ming】


class Solution {
// The highest bit number is 30
static final int HIGH_BIT = 30;
public int findMaximumXOR(int[] nums) {
int x = 0;
for (int k = HIGH_BIT; k >= 0; --k) {
Set<Integer> seen = new HashSet<Integer>();
// Will all pre^k(a_j) Put it in the hash table
for (int num : nums) {
// If you just want to keep it from the top to the bottom k The part that ends with two binary bits
// Just move it to the right k position
seen.add(num >> k);
}
// at present x From the top to the bottom k+1 The part that ends with two binary bits
// We will x Of the k Two binary positions are 1, That is to say x = x*2+1
int xNext = x * 2 + 1;
boolean found = false;
// enumeration i
for (int num : nums) {
if (seen.contains(xNext ^ (num >> k))) {
found = true;
break;
}
}
if (found) {
x = xNext;
} else {
// If you don't find one that satisfies the equation a_i and a_j, that x Of the k A binary bit can only be 0
// That is to say x = x*2
x = xNext - 1;
}
}
return x;
}
}
author :LeetCode-Solution
link :https://leetcode.cn/problems/ms70jA/solution/zui-da-de-yi-huo-by-leetcode-solution-hr7m/
source : Power button (LeetCode)
The copyright belongs to the author . Commercial reprint please contact the author for authorization , Non-commercial reprint please indicate the source .边栏推荐
- 12. Priority queue and inert queue
- The data source is SQL server. I want to configure the incremental data of the last two days of the date field updatedate to add
- BIO、NIO、AIO的区别和原理
- Lua language (stm32+2g/4g module) and C language (stm32+esp8266) methods of extracting relevant data from strings - collation
- View partition table format
- When defining an array, the size must be constant
- The return value of the function is the attention of the pointer, the local variables inside the static limit sub function, and how the pointer to the array represents the array elements
- MySQL gets the maximum value record by field grouping
- MPU6050
- Database SQL statement realizes function query of data decomposition
猜你喜欢

14.haproxy+keepalived负载均衡和高可用

10.回退消息

Blood cases caused by < meta charset=UTF-8> -- Analysis of common character codes

Object detection: object_ Detection API +ssd target detection model

Is the array name a pointer
![[Openstack] keystone,nova](/img/de/70b654a29a813c8fe828c4018bd4e7.png)
[Openstack] keystone,nova

AssertionError(“Torch not compiled with CUDA enabled“)

Machine vision series 3:vs2019 opencv environment configuration

Value transmission and address transmission of C language, pointer of pointer

11. Backup switch
随机推荐
12.优先级队列和惰性队列
The difference between dynamic, VaR and object in fluent
%s. %c, character constant, string constant, const char*, pointer array, string array summary
Mmdetection preliminary use
Design of environment detection system based on STM32 and Alibaba cloud
How to solve the problem of store ranking?
GBase 8a特殊场景下屏蔽 ODBC 负载均衡方式?
LCA board
Rhel8 patch package production
Solution: module 'xlrd' has no attribute 'open_ Error reporting of workbook '
When array is used as a function parameter, it is better to use the array size as a function parameter
[hands on deep learning] environment configuration (detailed records, starting from the installation of VMware virtual machine)
RMAN do not mark expired backups
9.延迟队列
C语言力扣第61题之旋转链表。双端队列与构造循环链表
Taobao product details interface (product details page data interface)
优炫数据库有办法查到主集群每天传给备集群的日志量吗?
有一种密码学专用语言叫做ASN.1
C language - character array - string array - '\0' -sizeof-strlen() -printf()
C语言:typedef知识点总结