We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8267d15 commit 0a68737Copy full SHA for 0a68737
elements-of-programming-interviews/cpp/parity.cc
@@ -1,7 +1,12 @@
1
#include "test_framework/generic_test.h"
2
short Parity(unsigned long long x) {
3
- // TODO - you fill in here.
4
- return 0;
+ bool parity = false;
+ int shifts = 0;
5
+ while (x) {
6
+ parity = (x & 1 ? !parity : parity);
7
+ x >>= 1;
8
+ }
9
+ return parity ? 1 : 0;
10
}
11
12
int main(int argc, char* argv[]) {
elements-of-programming-interviews/problem_mapping.js
@@ -16,7 +16,7 @@ problem_mapping = {
16
},
17
"4.01 Computing the parity of a word": {
18
"C++: parity.cc": {
19
- "passed": 0,
+ "passed": 10000,
20
"total": 10000
21
22
"Java: Parity.java": {
0 commit comments