Skip to content

Commit 3a741a1

Browse files
committed
Time: 41 ms (30.91%), Space: 18 MB (13.37%) - LeetHub
1 parent 6af8974 commit 3a741a1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# time complexity: O(n)
2+
# space complexity: O(1)
3+
class Solution:
4+
def countOperations(self, num1: int, num2: int) -> int:
5+
count = 0
6+
while num1 and num2:
7+
if num2 > num1:
8+
num2 -= num1
9+
else:
10+
num1 -= num2
11+
count += 1
12+
return count
13+
14+
15+
num1 = 2
16+
num2 = 3
17+
print(Solution().countOperations(num1, num2))
18+
num1 = 10
19+
num2 = 10
20+
print(Solution().countOperations(num1, num2))

0 commit comments

Comments
 (0)