Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d91c63a

Browse files
feat: add ts solution to lc problem: No.1725
No.1725.Number Of Rectangles That Can Form The Largest Square
1 parent abc8493 commit d91c63a

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

‎solution/1700-1799/1725.Number Of Rectangles That Can Form The Largest Square/README.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,24 @@ class Solution {
8888
}
8989
```
9090

91+
### **TypeSript**
92+
93+
```ts
94+
function countGoodRectangles(rectangles: number[][]): number {
95+
let maxLen = 0, ans = 0;
96+
for (let [l, w] of rectangles) {
97+
let k = Math.min(l, w,);
98+
if (k == maxLen) {
99+
ans++;
100+
} else if (k > maxLen) {
101+
maxLen = k;
102+
ans = 1;
103+
}
104+
}
105+
return ans;
106+
};
107+
```
108+
91109
### **C++**
92110

93111
```cpp

‎solution/1700-1799/1725.Number Of Rectangles That Can Form The Largest Square/README_EN.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,24 @@ class Solution {
8888
}
8989
```
9090

91+
### **TypeScript**
92+
93+
```ts
94+
function countGoodRectangles(rectangles: number[][]): number {
95+
let maxLen = 0, ans = 0;
96+
for (let [l, w] of rectangles) {
97+
let k = Math.min(l, w,);
98+
if (k == maxLen) {
99+
ans++;
100+
} else if (k > maxLen) {
101+
maxLen = k;
102+
ans = 1;
103+
}
104+
}
105+
return ans;
106+
};
107+
```
108+
91109
### **C++**
92110

93111
```cpp
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function countGoodRectangles(rectangles: number[][]): number {
2+
let maxLen = 0, ans = 0;
3+
for (let [l, w] of rectangles) {
4+
let k = Math.min(l, w,);
5+
if (k == maxLen) {
6+
ans++;
7+
} else if (k > maxLen) {
8+
maxLen = k;
9+
ans = 1;
10+
}
11+
}
12+
return ans;
13+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /