This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fill_tiles(N): | |
a=b=1 | |
for _ in range(N): | |
a,b=b,a+b | |
return a | |
print(fill_tiles(12)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bfs(graph, root): | |
visited = [] | |
queue = [root] | |
while queue: | |
node = queue.pop(0) | |
if node not in visited: | |
visited.append(node) | |
queue.extand(graph[node]) | |
return visited |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binary_search(arr, x): | |
if len(arr) == 0: | |
return False | |
elif len(arr) == 1: | |
return True if arr[0] == x else False | |
mid = len(arr)//2 | |
if arr[mid] == x: | |
return True | |
elif arr[mid] > x: |
NewerOlder