27 lines
521 B
Python
27 lines
521 B
Python
'''
|
|
Given three integers a, b, and c, return + if the equation a + b = c is true, and - if the equation a - b = c is true
|
|
|
|
Example 1
|
|
Input:
|
|
a = 1; b = 2; c = 3
|
|
Output:
|
|
+
|
|
Example 2
|
|
Input:
|
|
a = 2; b = 9; c = -7
|
|
Output:
|
|
-
|
|
'''
|
|
|
|
class Solution(object):
|
|
def solve(self, a:int, b:int, c:int) -> str:
|
|
if a + b == c:
|
|
return "+"
|
|
elif a - b == c:
|
|
return "-"
|
|
else:
|
|
return "0"
|
|
|
|
s = Solution()
|
|
print(s.solve(1, 2, 3)) # Output: "+"
|
|
print(s.solve(2, 9, -7)) # Output: "-" |