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
openapi: 3.0.3 | |
info: | |
title: r/SpaceX API V4 | |
version: 1.0.0 | |
contact: {} | |
servers: | |
- url: https://api.spacexdata.com | |
paths: | |
/v4/capsules: | |
get: |
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 depth_first_search(map, key, start): | |
if key == None: return [] | |
key = key.lower() if key.lower() in map else key.upper() | |
if not key in map: return [] | |
if map[key] == None: return [] | |
res = [] | |
for point in map[key]: | |
if point.lower() == start.lower(): | |
return [point] | |
path = depth_first_search(map, point, start) |
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 depth_first_search(map, key, visited): | |
if key == None: return None | |
key = key.lower() if key.lower() in map else key.upper() | |
if not key in map: return False | |
if map[key] == None: return False | |
for point in map[key]: | |
if point.lower() in visited: | |
return True | |
visited.add(key.lower()) | |
if depth_first_search(map, point, 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 convert_minutes(time_string): | |
hour, min = time_string.split(":") | |
hour, min = int(hour), int(min) | |
hour *= 60 | |
return hour + min | |
def findMinimumTimDiff(times): | |
if times == None or len(times) == 0: return 0 |
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
from collections import deque | |
def shuffleClass(arr, n): | |
if arr is None or len(arr) == 0: return [] | |
if n is None: return arr | |
arr = deque(arr) | |
if n >= 0: | |
for _ in range(n % len(arr)): | |
arr.appendleft(arr.pop()) |
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 mergeSortedList(l1, l2): | |
if l1 == None and l2 == None: | |
return [] | |
elif l1 != None and l2 == None: | |
return l1 | |
elif l2 != None and l1 == None: | |
return l2 | |
res = [] |
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 arrayProducts(arr): | |
if arr == None: return [] | |
if len(arr) == 1: return [0] | |
left_mul = 1 #this holds product so far from the left side | |
for i in range(len(arr)): | |
right_mul = 1 | |
for j in range(i+1, len(arr)): # this loops from the index of the current value + 1 to the end | |
right_mul *= arr[j] | |
temp_v = arr[i] |
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 findSortedPosition(nums, val): | |
if nums == None: return [-1, -1] | |
if val == None: return [-1, -1] | |
prev_num = None | |
nums_less = 0 | |
num_val = 0 | |
for num in nums: | |
if num < val: |
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 findSortedPosition(nums, val): | |
"This solution takes O(n) time complexity and O(1) space complexity" | |
if nums == None: return [-1, -1] | |
if val == None or type(val) != int: return [-1, -1] | |
nums_less = 0 | |
num_val = 0 | |
for num in nums: | |
if num < val: |
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 remove_all_instances(nums, val): | |
""" | |
This returns the number of values in num that isn't equal to val | |
its time complexity is O(n/2) because I used two pointers to navigate from left to right | |
and from right to left the both meet at p = n/2. while space O(1) | |
""" | |
if nums == None: return 0 | |
if val == None: return 0 |