当前位置:网站首页>1486. 数组异或操作
1486. 数组异或操作
2022-07-20 22:24:00 【baixiaofei567】
0到n-1就这样
class Solution {
public:
int xorOperation(int n, int start) {
//先求出每一位,然后依次异或,异或^相同为0,不同为1,所以一开始和0异或
int res = 0;
//下标从0开始,到n-1很重要
for(int i = 0; i < n; ++i){
res ^= (start + 2*i);
}
return res;
}
};
边栏推荐
- Is Ping An Securities a state-owned enterprise? Is it safe to open an account?
- Practice of data storage scheme in distributed system
- OneFlow v0.8.0正式发布
- Responsive dream weaving template poultry breeding website
- [leetcode] find an integer by dichotomy in the range
- Measurechildren's understanding
- ABAP(ALV部分)
- 百度工程师眼中的云原生可观测性追踪技术
- The penultimate K nodes in jz22 linked list
- Envoy load balancing and current limiting design
猜你喜欢
随机推荐
(pc+wap) Zhimeng template air purification website
使用MySQL,请用好 JSON 这张牌
cannot convert parameter 1 from 'class A' to 'class A'
Sliding of view
Selected papers of "deep neural network machine learning column"
消息队列-rockerMQ开发实战
已知文件名取文件所在目录
渗透测试成功的8个关键
【FLink】Flink 任务 如何优雅的停止
股票开户网上办理的话安全吗股票开户去哪里
Jz25 merge two sorted linked lists
几种常用登录的调试方式
【程序源代码】资讯小程序
自签名SAN证书
Scala wordcount case
Scala 练习题 学生分数案例
Jz67 converts strings to integers (ATOI)
听说你想手机玩扫雷?原生JS扫雷游戏
Envoy负载均衡与限流设计
前 3 名突然变了,揭秘 7 月编程语言最新排行榜