Skip to content

Instantly share code, notes, and snippets.

View IEdiong's full-sized avatar
👨‍🍳
Cooking

Ediongsenyene Joseph IEdiong

👨‍🍳
Cooking
View GitHub Profile
@IEdiong
IEdiong / containsDuplicate.js
Created December 19, 2021 00:49
LeetCode Data Structure I: Day 1 - 001
// 217. Contains Duplicate
// Easy
// Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
const containsDuplicate = (nums) => {
// create an empty dictionary
// iterate through the array
// for each integer in the array check if the integer position exists in the dictionary
// if 'yes' return 'true'
@IEdiong
IEdiong / minTimeDifference.py
Last active May 28, 2021 04:31
This program was created to help Esther (our fictitious client) to find the minimum time difference between any two of her wake up times recorded in her journal
from itertools import combinations
def minDifference(wakeTimes):
# if wakeTimes is an empty array
if not wakeTimes:
return 0
# creates an array of wakeTimes in minute
wakeTimesInMins = list(map( lambda x: int(x[0]) * 60 + int(x[1]), [ time.split(":") for time in wakeTimes ]))
@IEdiong
IEdiong / shuffleClass.py
Last active May 21, 2021 09:24
Algorithm Fridays Week 6
from collections import deque
def shuffleClass(listOfPupils, n):
#test if listOfPupils is a list, has none value or empty
if (not isinstance(listOfPupils, list)) or (not listOfPupils):
return []
#takes the last 'n' items to the front using 'deque'
else:
@IEdiong
IEdiong / array_product.py
Last active May 2, 2021 22:36
Algorithm Fridays Week 4
def prodOfNums(nums):
if len(nums) == 0:
return "invalid array: input an array of numbers"
else:
prod = 1
ans = []
for i in nums:
prod *= i
for i in range(0,len(nums)):
ans.append(prod // nums[i])