Skip to content
This repository was archived by the owner on Sep 22, 2021. It is now read-only.

Commit eb446c6

Browse files
committed
updated solution
1 parent 72d674e commit eb446c6

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed
Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
class Solution:
2-
def tribonacci(self, n: int) -> int:
3-
a, b, c = 0, 1, 1
4-
if n == 0:
5-
return 0
6-
elif n == 1 or n == 2:
7-
return 1
8-
else:
9-
for _ in range(n - 2):
10-
temp = a + b + c
11-
a = b
12-
b = c
13-
c = temp
14-
return temp
2+
def checkIfExist(self, arr: List[int]) -> bool:
3+
4+
seen = set()
5+
for x in arr:
6+
if x * 2 in seen or (not x % 2 and x // 2 in seen):
7+
return True
8+
seen.add(x)
9+
return False

0 commit comments

Comments
 (0)