forked from doocs/leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ts solution to lc problem: No.1725
No.1725.Number Of Rectangles That Can Form The Largest Square
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
solution/1700-1799/1725.Number Of Rectangles That Can Form The Largest Square/Solution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |