Skip to content

Commit

Permalink
feat: add ts solution to lc problem: No.1725
Browse files Browse the repository at this point in the history
No.1725.Number Of Rectangles That Can Form The Largest Square
  • Loading branch information
zhaocchen committed Feb 4, 2022
1 parent abc8493 commit d91c63a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@ class Solution {
}
```

### **TypeSript**

```ts
function countGoodRectangles(rectangles: number[][]): number {
let maxLen = 0, ans = 0;
for (let [l, w] of rectangles) {
let k = Math.min(l, w,);
if (k == maxLen) {
ans++;
} else if (k > maxLen) {
maxLen = k;
ans = 1;
}
}
return ans;
};
```

### **C++**

```cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@ class Solution {
}
```

### **TypeScript**

```ts
function countGoodRectangles(rectangles: number[][]): number {
let maxLen = 0, ans = 0;
for (let [l, w] of rectangles) {
let k = Math.min(l, w,);
if (k == maxLen) {
ans++;
} else if (k > maxLen) {
maxLen = k;
ans = 1;
}
}
return ans;
};
```

### **C++**

```cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function countGoodRectangles(rectangles: number[][]): number {
let maxLen = 0, ans = 0;
for (let [l, w] of rectangles) {
let k = Math.min(l, w,);
if (k == maxLen) {
ans++;
} else if (k > maxLen) {
maxLen = k;
ans = 1;
}
}
return ans;
};

0 comments on commit d91c63a

Please sign in to comment.