Skip to content

Instantly share code, notes, and snippets.

View KingAshiru's full-sized avatar

Tobi Ashiru KingAshiru

View GitHub Profile
class Solution:
def findMinDiff(self, times):
if len(times) < 1:
return 0
timelist = []
# convert all times to minutes
for time in times:
minutes = int(time[0:2]) * 60 + int(time[3:5])
minutes2 = minutes + (24 * 60) # we need to cover for times closer to midnight (00:00)
timelist.append(minutes2)
@KingAshiru
KingAshiru / product.py
Last active May 2, 2021 17:07
ArrayProducts
class Solution:
def arrayProduct(self, nums):
#check for edge cases
if not nums:
return None
if len(nums) < 2:
return 0
#we create an array of 1s, which would be our final output
res = [1]*len(nums)
class Solution:
def findPosition(self, array, val):
position = [-1, -1]
if not array or not val:
return position
if type(val) is not int:
return position
if len(array) == 0:
return position
class Solution:
def removeElement(self, nums, val) -> int:
# check for edge cases of None array, None value, or invalid values such as strings
if not nums:
return 0
if (not val) or (type(val) is not int) or (type(val) is not float):
return len(nums)
nextNonKey = 0
i = 0
class Solution:
def removeDuplicates(self, nums):
#check for cases of an empty array
if len(nums) == 0:
return 0
nextNonDuplicate = 1
i = 1
#since the array is sorted, all duplicates would be adjacent,