Skip to content

Instantly share code, notes, and snippets.

View Abiola-Farounbi's full-sized avatar

Abiola Abiola-Farounbi

View GitHub Profile
@Abiola-Farounbi
Abiola-Farounbi / productOfArray.js
Created May 1, 2021 21:08
The function returns products of element in an array
//Given an integer array nums,
//write a function that returns an array products,
//such that each entry at position i, in products is a product of all the other elements in nums except num[i]
// #algorithm friday set4
const productOfArray = (nums) => {
// testing for array or empty array
if (!Array.isArray(nums) || nums.length == 0 ) return ' Invalid Input '
@Abiola-Farounbi
Abiola-Farounbi / getStartAndEndPosition.js
Last active April 27, 2021 19:47
This function returns the start and end postion of a value in a sorted array
//Problem set
//Given an unsorted array nums, write a function to find the start and end positions of a given number val in the array after sorting it.
const getStartAndEndPosition = (nums,val) =>{
//if nums is empty or null
if (!nums || nums.length === 0) { return [-1,-1]};
//sorting the array