当前位置:网站首页>leetcode1720_ 2021-10-14
leetcode1720_ 2021-10-14
2022-06-24 21:53:00 【Programming rookie】
leetcode1720_ Decode the XOR array
This is a very simple topic . The purpose of this blog is to introduce the characteristics of XOR symbol .
Some basic theorems about XOR operation :
XOR satisfies the law of association ,(a ^ b) ^ c = a ^ (b ^ c)
XOR satisfies the law of exchange ,a ^ b = b ^ a
Any number is exclusive or with itself 0,a^a = 0
Any number XOR 0 To oneself ,a^0 = a
that encoded[i] = arr[i] ^ arr[i + 1], Then there are arr[i + 1] = encoded[i] ^ ar[i].
class Solution {
public:
vector<int> decode(vector<int>& encoded, int first) {
vector<int> arr(encoded.size() + 1);
arr[0] = first;
for(int i = 0; i < encoded.size(); ++i){
arr[i + 1] = encoded[i] ^ arr[i];
}
return arr;
}
};
There are a few classic questions about XOR :( The following topics will be updated from time to time )
leetcode Exchange numbers —— Super classic title
边栏推荐
- Tournament sort
- 2022 international women engineers' Day: Dyson design award shows women's design strength
- 网络层 && IP
- Redis+Caffeine两级缓存,让访问速度纵享丝滑
- WMI and PowerShell get TCP connection list
- [精选] 多账号统一登录,你如何设计?
- SAP接口debug设置外部断点
- 介绍BootLoader、PM、kernel和系统开机的总体流程
- How to resolve the 35 year old crisis? Sharing of 20 years' technical experience of chief architect of Huawei cloud database
- 123. the best time to buy and sell shares III
猜你喜欢

Graduation design of phase 6 of the construction practice camp

Blender's landscape
![[product design and R & D collaboration tool] Shanghai daoning provides you with blue lake introduction, download, trial and tutorial](/img/0f/e0b261496d04ca3da8a7d7d19e5bf1.png)
[product design and R & D collaboration tool] Shanghai daoning provides you with blue lake introduction, download, trial and tutorial

(to be added) games101 job 7 improvement - knowledge you need to know to realize micro surface model

为什么生命科学企业都在陆续上云?
![[camera Foundation (I)] working principle and overall structure of camera](/img/5d/c29d636a90d01e5c3852df2a0dd833.png)
[camera Foundation (I)] working principle and overall structure of camera

Datakit agent realizes unified data aggregation in LAN

Transport layer UDP & TCP

Advanced secret of xtransfer technology newcomers: the treasure you can't miss mentor

ping: www.baidu. Com: unknown name or service
随机推荐
openGauss内核:简单查询的执行
03---增反膜
Web project deployment
Volcano becomes spark default batch scheduler
Advanced secret of xtransfer technology newcomers: the treasure you can't miss mentor
CondaValueError: The target prefix is the base prefix. Aborting.
Graduation design of phase 6 of the construction practice camp
【论】Deep learning in the COVID-19 epidemic: A deep model for urban traffic revitalization index
Introduce the overall process of bootloader, PM, kernel and system startup
TypeScript快速入门
多线程收尾
188. the best time to buy and sell stocks IV
2022 international women engineers' Day: Dyson design award shows women's design strength
123. the best time to buy and sell shares III
力扣每日一题-第25天-496.下一个更大元素Ⅰ
MySQL optimizes query speed
排查到解决问题的过程:浏览器突然无法访问网页,错误代码:0x80004005,最终定位:“电脑打开热点,电脑就不能上网了”
Functional analysis of ebpf tracepoint
旅行商问题(TSP)的相关论文总结
升哲科技 AI 智能防溺水服务上线