Cover image for LeetCode Daily Problem P2169 Number of Operations to Make 0

LeetCode Daily Problem P2169 Number of Operations to Make 0


Timeline

timeline

2025-11-09

init

simulation

Problem:

Weekend bonus problem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <algorithm>
class Solution {
public:
int countOperations(int num1, int num2)
{
int ops = 0;
while (num1 != 0 && num2 != 0) {
if (num1 < num2) { //num1 is the larger one
std::swap(num1, num2);
}
num1 = num1 - num2;
ops++;
}
return ops;
}
};