Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "coins.h"
- #include <vector>
- std::vector<int> coin_flips(std::vector<int> b, int c) {
- int xor_all = 0;
- for(int i = 0; i < (int) b.size(); i++) {
- if(b[i]) {
- xor_all ^= i;
- }
- }
- std::vector<int> v = {c ^ xor_all};
- return v;
- }
- int find_coin(std::vector<int> b) {
- int xor_result = 0;
- for(int i = 0; i < (int) b.size(); i++) {
- if(b[i]) {
- xor_result ^= i;
- }
- }
- return xor_result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement