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
//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 ' |
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
//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 |
NewerOlder