当前位置:网站首页>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
边栏推荐
- 机器学习:线性回归
- Memcached comprehensive analysis – 5 Memcached applications and compatible programs
- Li Kou daily question - day 26 -496 Next larger element I
- Network layer & IP
- Volcano becomes spark default batch scheduler
- leetcode_191_2021-10-15
- Several classes of manual transactions
- Li Kou daily question - day 25 -496 Next larger element I
- 心楼:华为运动健康的七年筑造之旅
- The collection of zero code enterprise application cases in various industries was officially released
猜你喜欢
Volcano成Spark默认batch调度器
二叉搜索树模板
Visit Amazon memorydb and build your own redis memory database
socket(1)
Blender's simple skills - array, rotation, array and curve
我国SaaS产业的发展趋势与路径
leetcode-201_2021_10_17
Multi task model of recommended model: esmm, MMOE
[notes of Wu Enda] convolutional neural network
《各行业零代码企业应用案例集锦》正式发布
随机推荐
how to install clustershell
Antdb database online training has started! More flexible, professional and rich
Pattern recognition - 0 introduction
手动事务的几个类
Fuzhou business office of Fujian development and Reform Commission visited the health department of Yurun university to guide and inspect the work
排查到解决问题的过程:浏览器突然无法访问网页,错误代码:0x80004005,最终定位:“电脑打开热点,电脑就不能上网了”
如何做到全彩户外LED显示屏节能环保
Multiplexer select
(待补充)GAMES101作业7提高-实现微表面模型你需要了解的知识
Web project deployment
Elegant custom ThreadPoolExecutor thread pool
Volcano成Spark默认batch调度器
That is to say, "live broadcast" is launched! One stop live broadcast service with full link upgrade
Kubernetes 集群中流量暴露的几种方案
建木持续集成平台v2.5.0发布
福建省发改委福州市营商办莅临育润大健康事业部指导视察工作
Based on asp Net development of fixed assets management system source code enterprise fixed assets management system source code
Volcano becomes spark default batch scheduler
Graduation summary of phase 6 of the construction practice camp
火狐拖放后,总会默认打开百度搜索,如果是图片,则会打开图片。