Data Structure Array: Find the two numbers with odd occurrences in an unsorted array
http://www.geeksforgeeks.org/find-the-two-numbers-with-odd-occurences-in-an-unsorted-array/
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <fstream>
#include <map>
using namespace std; void printtwoodd(int arr[], int n) {
int x = arr[];
for (int i = ; i < n; i++) x ^= arr[i];
x &= ~(x-);
int ans1, ans2;
ans1 = ans2 = ;
for (int i = ; i < n; i++) {
if (arr[i] & x) ans1 ^= arr[i];
else ans2 ^= arr[i];
}
cout << ans1 << " " << ans2 << endl;
} int main() {
int arr[] = {, , , , , , , };
printtwoodd(arr, );
return ;
}
Data Structure Array: Find the two numbers with odd occurrences in an unsorted array的更多相关文章
- [Algorithm] Heap data structure and heap sort algorithm
Source, git Heap is a data structure that can fundamentally change the performance of fairly common ...
- [LeetCode] 170. Two Sum III - Data structure design 两数之和之三 - 数据结构设计
Design and implement a TwoSum class. It should support the following operations:add and find. add - ...
- [LeetCode] Two Sum III - Data structure design 两数之和之三 - 数据结构设计
Design and implement a TwoSum class. It should support the following operations:add and find. add - ...
- ✡ leetcode 170. Two Sum III - Data structure design 设计two sum模式 --------- java
Design and implement a TwoSum class. It should support the following operations: add and find. add - ...
- LeetCode Two Sum III - Data structure design
原题链接在这里:https://leetcode.com/problems/two-sum-iii-data-structure-design/ 题目: Design and implement a ...
- LeetCode 笔记27 Two Sum III - Data structure design
Design and implement a TwoSum class. It should support the following operations: add and find. add - ...
- hdu 4217 Data Structure? 树状数组求第K小
Data Structure? Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- leetcode3 Two Sum III – Data structure design
Question: Design and implement a TwoSum class. It should support the following operations: add and f ...
- 170. Two Sum III - Data structure design
题目: Design and implement a TwoSum class. It should support the following operations: add and find. a ...
随机推荐
- 记录:Android中StackOverflow的问题
最近新作的项目上线,出现了一个让人抓狂的问题.在此记录一下! 现在的项目中,制作了一个界面非常复杂.整个结构是最外层一个Layout,封装了Menu键吊起的菜单,整个内容使用一个FrameLayout ...
- 查看Tomcat状态页,管理app,主机管理
Server Status 通过点击这个按钮我们可以查看Tomcat的状态,点击,弹出403错误页面 通过查看官方文档 因此,创建manager.xml # cat /usr/local/tomcat ...
- lua学习笔记(十一)
面向对象编程 对象的实现 在lua中table就是一种对象 1.有自己的状态 2.有自己的唯一标识self 3.有自己的生命周期 ...
- [译]NeHe教程 - 创建一个OpenGL窗体
原文: Setting Up An OpenGL Window 欢迎阅读我的OpenGL教程.我是一个热爱OpenGL的普通码农!我第一次听到OpenGL是在3Dfx刚发布他们给Voodoo I显卡的 ...
- Jquery 中Ajax使用的四种情况
<script type="text/javascript" language="javascript" src="JS/jquery-1[1] ...
- Nginx 变量漫谈
转自:http://blog.sina.com.cn/openrestyNginx 的配置文件使用的就是一门微型的编程语言,许多真实世界里的 Nginx 配置文件其实就是一个一个的小程序.当然,是不是 ...
- UFLDL深度学习笔记 (五)自编码线性解码器
UFLDL深度学习笔记 (五)自编码线性解码器 1. 基本问题 在第一篇 UFLDL深度学习笔记 (一)基本知识与稀疏自编码中讨论了激活函数为\(sigmoid\)函数的系数自编码网络,本文要讨论&q ...
- python3读取HDA零售企业数据(一)
#-*- coding:utf-8 -*- # 下载河南FDA各药品经营企业目录 import urllib.request import urllib.parse import re import ...
- win10中如何成功安装lxml
lxml官网地址:http://lxml.de/index.html 问题: 在学习lxm的时候,发现在win10下总是安装失败,如下: 在网上搜索了半天也没找到具体的解决方案,就FQgoogle下, ...
- Linux中的提示符
root的提示符:# 一般用户的提示符:$