Movatterモバイル変換


[0]ホーム

URL:


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

Commit65fcec7

Browse files
rectangle area
1 parent648c5ca commit65fcec7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

‎EASY/src/easy/RectangleArea.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
packageeasy;
2+
3+
publicclassRectangleArea {
4+
5+
publicintcomputeArea(intA,intB,intC,intD,intE,intF,intG,intH) {
6+
intareaA = (C-A)*(D-B);
7+
intareaB = (G-E)*(H-F);
8+
9+
inttop =Math.min(D,H);
10+
intbottom =Math.max(B,F);
11+
intleft =Math.max(A,E);
12+
intright =Math.min(C,G);
13+
14+
intoverlap =0;
15+
if(top >bottom &&right >left)overlap = (top -bottom)*(right -left);
16+
returnareaA +areaB -overlap;
17+
}
18+
19+
}

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
|278|[First Bad Version](https://leetcode.com/problems/first-bad-version/)|[Solution](../../blob/master/EASY/src/easy/FirstBadVersion.java)| O(logn)|O(1) | Easy| Binary Search
2626
|273|[Integer to English Words](https://leetcode.com/problems/integer-to-english-words/)|[Solution]|
2727
|257|[Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths/)|[Solution](../../blob/master/EASY/src/easy/BinaryTreePaths.java) | O(n*h) | O(h) | DFS/Recursion
28+
|223|[Rectangle Area](https://leetcode.com/problems/rectangle-area/)|[Solution](../../blob/master/EASY/src/easy/RectangleArea.java)| O(1)|O(1)| Easy|
2829
|209|[Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum/)|[Solution](../../blob/master/MEDIUM/src/medium/MinimumSizeSubarraySum.java)| O(n)|O(1)| Medium|
2930
|206|[Reverse Linked List](https://leetcode.com/problems/reverse-linked-list/)|[Solution](../../blob/master/EASY/src/easy/ReverseLinkedList.java)| O(n)|O(1) | Easy
3031
|205|[Isomorphic Strings](https://leetcode.com/problems/isomorphic-strings/)|[Solution](../../blob/master/EASY/src/easy/IsomorphicStrings.java)| O(n)|O(1) | Easy

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp