Skip to content

Instantly share code, notes, and snippets.

@IEdiong
Last active May 2, 2021 22:36
Show Gist options
  • Save IEdiong/0c75d03221a1c712ff42e70d8700eeae to your computer and use it in GitHub Desktop.
Save IEdiong/0c75d03221a1c712ff42e70d8700eeae to your computer and use it in GitHub Desktop.
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])
return ans
@IEdiong
Copy link
Author

IEdiong commented May 2, 2021

Hello @meekg33k, thank you for the feedback.

I did not consider this particular test case, but I must confess that my mind is being expanded as I participate in this challenge.

I did do some brainstorming for a better way that doesn't involve me creating a new ans array, but I couldn't come up with something good. Please I'm open to corrections and suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment