Instantly share code, notes, and snippets.

Tobi Ashiru KingAshiru

Created May 22, 2021 01:00
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
 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)
Last active May 2, 2021 17:07
ArrayProducts
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
 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)
Created April 25, 2021 09:55
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
 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
Last active April 19, 2021 17:32
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
 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
Last active April 13, 2021 05:35
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
 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,