Skip to content

Commit 381367b

Browse files
committed
2019-08-03
1 parent 8efd7f0 commit 381367b

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution(object):
2+
def computeArea(self, A, B, C, D, E, F, G, H):
3+
"""
4+
:type A: int
5+
:type B: int
6+
:type C: int
7+
:type D: int
8+
:type E: int
9+
:type F: int
10+
:type G: int
11+
:type H: int
12+
:rtype: int
13+
"""
14+
# [A, C]ºÍ[E, G]È¡½»¼¯, [B, D]ºÍ[F, H]È¡½»¼¯
15+
if min(C, G) - max(A, E) < 0 or min(D, H) - max(B, F) < 0:
16+
S_overlap = 0
17+
else:
18+
S_overlap = (min(C, G) - max(A, E)) * (min(D, H) - max(B, F))
19+
S_first_square = (D - B) * (C - A)
20+
S_second_square = (H - F) * (G - E)
21+
# print S_second_square, S_first_square, S_overlap
22+
return S_second_square + S_first_square - S_overlap

0226.翻转二叉树/0226-翻转二叉树.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ def invertTree(self, root):
1515
return root
1616
left = root.left
1717
right = root.right
18-
root.right = self.invertTree(left)
1918
root.left = self.invertTree(right)
20-
return root
21-
22-
19+
root.right = self.invertTree(left)
20+
return root

0 commit comments

Comments
 (0)