AmitDiwan has Published 10744 Articles

Finding maximum number from two arrays in JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Mar-2021 05:35:27

642 Views

ProblemWe are required to write a JavaScript function that takes in two arrays of single digit numbers representing two numbers, arr1 and arr2 as the first and second argument. The third argument to the function will be a number, num (num {    const map = new Map();   ... Read More

Summing up to amount with fewest coins in JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Mar-2021 05:31:46

179 Views

ProblemWe are required to write a JavaScript function that takes in arr, arr, as the first argument. This array basically specifies the different types of coin denominations we have.The second argument to the function is a number, amount, which specifies the amount we want to add up to. Our function ... Read More

Uneven sorting of array in JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Mar-2021 05:29:41

205 Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers, arr, as the only argument. Our function should sort this array in such a way that after sorting, the elements should follow this pattern −arr[0] < arr[1] > arr[2] < arr[3]....For example, if the input ... Read More

Counting pairs with range sum in a limit in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Mar-2021 06:17:22

280 Views

Range SumRange sum rangeSum(i, j) is defined as the sum of the elements in an array between indices i and j (i ≤ j), inclusive.ProblemWe are required to write a JavaScript function that takes in an array of Integers, arr, as the first argument and two numbers, upper and lower ... Read More

Longest path in 2-D that contains increasing sequence in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Mar-2021 06:15:12

321 Views

Increasing SequenceA sequence of numbers in which each succeeding element is either greater or equal to the preceding element is an increasing sequence.For instance, 4, 6, 8, 9, 11, 14 is increasing sequence 3, 3, 3, 3, 3, 3, 3 is also an increasing sequenceProblem:We are required to write a ... Read More

Adding elements to array to make its sum diverse in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Mar-2021 06:10:49

126 Views

ProblemWe are required to write a JavaScript function that takes in an array of Numbers, arr, as the first argument and a single number, num, as the second argument.We should, by adding elements to it, make our array such that any sum can be obtained by adding specific numbers from ... Read More

Checking for increasing triplet in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Mar-2021 06:07:44

266 Views

Increasing Numbers:A sequence of numbers in which each succeeding element is either greater or equal to the preceding element is an increasing sequence.For instance, 4, 6, 8, 9, 11, 14 is increasing sequence 3, 3, 3, 3, 3, 3, 3 is also an increasing sequenceProblemWe are required to write a ... Read More

Joining strings to form palindrome pairs in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Mar-2021 06:02:16

265 Views

ProblemWe are required to write a JavaScript function that takes in an array of strings as the only argument. The function is supposed to return an array of arrays of all the index pairs joining the strings at which yields a new palindrome string.For example, if the input to the ... Read More

Calculating 1s in binary representation of numbers in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Mar-2021 05:59:46

461 Views

ProblemWe are required to write a JavaScript function that takes in a single Integer, num, as the first and the only argument. Our function should prepare an array for every number between 0 and num (including both of them), for each number, the corresponding element should be the number of ... Read More

Weight sum of a nested array in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Mar-2021 05:55:59

482 Views

ProblemWe are required to write a JavaScript function that takes in a nested array, arr (nested up to any level) as the only argument.The function should calculate the weighted sum of the nested array and return that sum.For calculating nested sum, we multiply a specific element with its level of ... Read More

Advertisements