Skip to content

Instantly share code, notes, and snippets.

View BeardOfDan's full-sized avatar
🎯
Focusing

Daniel Roberts BeardOfDan

🎯
Focusing
  • Bay Area, Ca
View GitHub Profile

Keybase proof

I hereby claim:

  • I am beardofdan on github.
  • I am beardofdan (https://keybase.io/beardofdan) on keybase.
  • I have a public key ASDgeGA7gZBLDIiGxZKSFah9h559CzQZopPH73cLPMRnyQo

To claim this, I am signing this object:

// it said no new data structs, but this is for defining what a vowel is,
// not holding a 'working' string or anything like that,
// so I'll just let this be a thing here
var vowels = ['a', 'e', 'i', 'o', 'u'];
// an iterative approach
// would be somewhat over O(2n), but since the constant is dropped for big O notation, it becomes O(n)
var vowelDoubler = (arr) => {
const len = arr.length;
var productExceptSelf = function(nums) {
const result = [];
let product = 1;
let zeroCount = 0; // keeps track of if there are multiple zeros in the array
for (let i = 0; i < nums.length; i++) {
if (nums[i] !== 0) {
product *= nums[i];
} else {
zeroCount++;