MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / xorOperation

Method xorOperation

XOROperationInAnArray.java:2–12  ·  view source on GitHub ↗
(int n, int start)

Source from the content-addressed store, hash-verified

1class Solution {
2 public int xorOperation(int n, int start) {
3
4 int res=start;
5 for(int i=0;i<n-1;i++)
6 {
7 int x=(res | (start + 2*(i+1)));
8 int y=(~res | ~(start + 2*(i+1)));
9 res = (x&y);
10 }
11 return res;
12 }
13}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected