当前位置:网站首页>421. 数组中两个数的最大异或值
421. 数组中两个数的最大异或值
2022-06-11 01:07:00 【Melody2050】
前缀树思路
https://www.youtube.com/watch?v=wSgrc98d2lI
假设有5个数字,二进制如下:
- 00010
- 00101
- 01000
- 01010
- 11001
将它们存储到前缀树如下图。
每次,我们看向一个数字,从高位向低位查找,从所有选择中找到能与他组成最大异或结果的数。

如上图,我们先看向数字11001,尝试为他找到最佳搭配。
- 最高位是1,如果另一个数字高位是0,就能组成最大结果。而前缀树的根节点有0子节点,所以我们来到0。
- 第二位也是1,所以从子节点选择另一个0。
- 第三位是0,最佳搭配的第三位需要是1,于是我们走向1子节点。
- 以此类推,在查找前缀树时,优先选择最佳搭配的子节点,如果不行,才选另一个。
最后返回与最佳搭配的计算结果。
边栏推荐
- 聊聊一个注解实现接口重试
- 我们对于产业互联网的认识,或许更多的要跳出现有的逻辑之外
- The interviewer of Tencent said that who knows the internal module index principle and performance optimization idea of MySQL architecture?
- [QT] error: qapplication: no such file or directory solution
- Enrichment of core knowledge points of interface automation to add points to the interview
- Battery control of QT widget (qpainter)
- Within one month, the broadcasting volume has increased by 9million, and station B has three traffic growth passwords!
- During SSH configuration key login, you need to pay attention to whether the private key is set with a password
- Internet of things final assignment - sleep quality detection system (refined version)
- Deep exploration of functions with indefinite parameters in C language
猜你喜欢
![Md61 plan independent demand import Bapi [by daily dimension / dynamic template / dynamic field]](/img/28/2a4fd7f019f6528bd322c5e75ecaa7.png)
Md61 plan independent demand import Bapi [by daily dimension / dynamic template / dynamic field]

记录一下我的刷题实录

Ortele has obtained three rounds of financing nine months after its establishment, and hard discount stores have found new ways to grow?

Polynomial multiplication

Me11/me12 purchase information record and condition record creation and update bapi:me_ INFORECORD_ MAINTAIN_ MULTI

In May, the main growth ranking list (platform of station B) of the single flying melon data up was released

QT database learning notes (I) basic concepts of database

Shader of double sided material
![[3.delphi common components] 6 scroll bar](/img/55/891e56de4500a9128ac89e3c5b1721.jpg)
[3.delphi common components] 6 scroll bar

The annual salary of testers in large factories ranges from 300000 to 8K a month. Roast complained that the salary was too low, but he was ridiculed by netizens?
随机推荐
Shell learning tutorial (super detailed and complete)
NFT Insider #61:Animoca Brands 在 340 项投资中持有 15 亿美元的加密资产
MD61计划独立需求导入BAPI【按日维度/动态模板/动态字段】
Rewrite: kms activates office2016, 2019 and 2021 with error code: 0xc004f069
Introduction and practice of QT tcp/udp network protocol (II) UDP communication
In the past 10 years, from zero foundation testing to test architect, he has made himself successful
Analysis of common ADB commands
[3.delphi common components] 4 Select class component
Dinner a bang's Craft
我们对于产业互联网的认识,或许更多的要跳出现有的逻辑之外
switch case使用枚举类来比较
[C language] storage of data in memory -1 plastic
Metersphere tutorial: how to assert when the returned result of the interface is null
Enrichment of core knowledge points of interface automation to add points to the interview
AI fanaticism | come to this conference and work together on the new tools of AI!
Initialize the one-dimensional array a correctly
Task01: be familiar with the basic process of news recommendation system
[music] playing "over fire" based on MATLAB [including Matlab source code 1875]
软件测试面试复盘:技术面没有难倒我,hr面却是一把挂
Polynomial multiplication