Skip to content

Commit cd54db8

Browse files
committed
feat: add typescript solution to lc problem: No.2169
No.2169.Count Operations to Obtain Zero
1 parent 3b416ca commit cd54db8

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

solution/2100-2199/2169.Count Operations to Obtain Zero/README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@
7575
### **TypeScript**
7676

7777
```ts
78-
78+
function countOperations(num1: number, num2: number): number {
79+
let ans = 0;
80+
while (num1 && num2) {
81+
[num1, num2] = [Math.min(num1, num2), Math.abs(num1 - num2)];
82+
ans++;
83+
}
84+
return ans;
85+
};
7986
```
8087

8188
### **...**

solution/2100-2199/2169.Count Operations to Obtain Zero/README_EN.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@ So the total number of operations required is 1.
6565
### **TypeScript**
6666

6767
```ts
68-
68+
function countOperations(num1: number, num2: number): number {
69+
let ans = 0;
70+
while (num1 && num2) {
71+
[num1, num2] = [Math.min(num1, num2), Math.abs(num1 - num2)];
72+
ans++;
73+
}
74+
return ans;
75+
};
6976
```
7077

7178
### **...**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function countOperations(num1: number, num2: number): number {
2+
let ans = 0;
3+
while (num1 && num2) {
4+
[num1, num2] = [Math.min(num1, num2), Math.abs(num1 - num2)];
5+
ans++;
6+
}
7+
return ans;
8+
};

0 commit comments

Comments
 (0)