Skip to content
This repository was archived by the owner on Sep 22, 2021. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
updated solution
  • Loading branch information
Karnak123 committed Oct 10, 2020
commit eb446c6e24a2f87ad3ba20f45383267b5ecf4a85
21 changes: 8 additions & 13 deletions LeetCode/1346_Check_if_N_and_its_Double_Exist.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
class Solution:
def tribonacci(self, n: int) -> int:
a, b, c = 0, 1, 1
if n == 0:
return 0
elif n == 1 or n == 2:
return 1
else:
for _ in range(n - 2):
temp = a + b + c
a = b
b = c
c = temp
return temp
def checkIfExist(self, arr: List[int]) -> bool:

seen = set()
for x in arr:
if x * 2 in seen or (not x % 2 and x // 2 in seen):
return True
seen.add(x)
return False