AmitDiwan has Published 10744 Articles

Count and return the number of characters of str1 that makes appearances in str2 using JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 10:02:27

158 Views

ProblemWe are required to write a JavaScript function that takes in two strings, str1 and str2 as the first and second argument respectively.Our function should count and return the number of characters of str1 that makes appearances in str2 as well, and if there are repetitive appearances, we have to ... Read More

Creating permutations by changing case in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 10:01:22

242 Views

ProblemWe are required to write a JavaScript function that takes in a string of characters, str, as the first and the only argument.Our function can transform every letter individually to be lowercase or uppercase to create another string. And we should return a list of all possible strings we could ... Read More

Making two sequences increasing in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 09:58:36

215 Views

Strictly Increasing SequenceA sequence is strictly increasing if and only if arr[0] < arr[1] < arr[2] < ... < arr[arr.length - 1].ProblemWe are required to write a JavaScript function that takes in two arrays of numbers, arr1 and arr2 as the first and the second argument respectively.We can swap any ... Read More

Greatest sum of average of partitions in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 09:57:59

119 Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers, arr, as the first argument, and a number, num, (num {    const sum = (arr = []) => arr.reduce((acc, num) => acc + num, 0)    let matrix = new Array(num + 1).fill(0).map(() ... Read More

Corresponding shortest distance in string in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 09:57:22

196 Views

ProblemWe are required to write a JavaScript function that takes in a string of English lowercase alphabets, str, as the first argument and a single character, char, which exists in the string str, as the second argument.Our function should prepare and return an array which, for each character in string ... Read More

Implementing circular queue ring buffer in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 09:55:46

1K+ Views

Circular QueueThe circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. It is also called "Ring Buffer".One of the benefits of the circular ... Read More

Flip the matrix horizontally and invert it using JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 09:55:05

1K+ Views

ProblemWe are required to write a JavaScript function that takes in a 2-D binary array, arr, (an array that consists of only 0 or 1), as the first and the only argument.Our function should first flip the matrix horizontally, then invert it, and return the resulting matrix.To flip the matrix ... Read More

Maximum length of mountain in an array using JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 09:53:01

255 Views

Mountain SubsequenceWe call any (contiguous) subarray sub (of arr) a mountain if the following properties hold −sub.length >= 3There exists some 0 < i < sub.length - 1 such that sub[0] < sub[1] < ... sub[i-1] < sub[i] > B[i+1] > ... > sub[sub.length - 1]ProblemWe are required to write ... Read More

Rearranging cards into groups in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 09:50:10

171 Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers, arr, as the first argument and a number, num, as the second argument.The numbers in the array are in the range [1, 13], limits inclusive, representing the 1-based index of playing cards.Our function should determine ... Read More

Finding peak of a centrally peaked array in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 09:44:10

367 Views

Centrally Peaked ArrayWe call an array arr a centrally peaked array if the following properties hold −arr.length >= 3There exists some i with 0 < i < arr.length - 1 such thatarr[0] < arr[1] < ... arr[i-1] < arr[i]arr[i] > arr[i+1] > ... > arr[arr.length - 1]ProblemWe are required to ... Read More

Advertisements