MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / Solution

Class Solution

LeetCode_problems/XOR Operation in an Array/solution.py:1–12  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution:
2 def xorOperation(self, n: int, start: int) -> int:
3 # build the initial array of numbers following the formula
4 nums = list()
5 for i in range(n):
6 nums.append(2 * i + start)
7
8 # compute the xor of all of the numbers
9 xor = nums[0]
10 for num in nums[1:]:
11 xor ^= num
12 return xor

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected