Please solve the programming task below using a self-contained code snippet in a markdown code block.

You are given a positive integer n, you can do the following operation any number of times:

Add or subtract a power of 2 from n.

Return the minimum number of operations to make n equal to 0.
A number x is power of 2 if x == 2i where i >= 0.
 
Please complete the following python code precisely:
```python
class Solution:
    def minOperations(self, n: int) -> int:
```