AmitDiwan has Published 10744 Articles

Check if the string is a combination of strings in an array using JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Nov-2020 06:58:11

179 Views

We are required to write a JavaScript function that takes in an array of strings as the first argument and a string as the second argument.The function should check whether the string specified by second argument can be formed by combining the strings of the array in any possible way.For ... Read More

Subset with maximum sum in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Nov-2020 06:55:04

330 Views

We are required to write a JavaScript function that takes in an array of integers. Our function is required find the subset of non−adjacent elements with the maximum sum.And finally, the function should calculate and return the sum of that subset.For example −If the input array is −const arr = ... Read More

Are the strings anagrams in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Nov-2020 06:51:07

177 Views

Anagrams −Two strings are said to be anagrams of each other if by rearranging, rephrasing or shuffling the first we can form a string identical to the second.For example −'something' and 'emosghtin' are anagrams of each other.We are required to write a JavaScript function that takes in two string, say ... Read More

Find what numbers were pressed to get the word (opposite of phone number digit problem) in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Nov-2020 06:49:38

156 Views

The mapping of the numerals to alphabets in the old keypad type phones used to be like this −const mapping = {    1: [],    2: ['a', 'b', 'c'],    3: ['d', 'e', 'f'],    4: ['g', 'h', 'i'],    5: ['j', 'k', 'l'],    6: ['m', 'n', 'o'], ... Read More

Finding product of an array using recursion in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Nov-2020 06:48:32

622 Views

We are required to write a JavaScript function that takes in an array of Integers. Our function should do the following two things −Make use of a recursive approach.Calculate the product of all the elements in the array.And finally, it should return the product.For example −If the input array is ... Read More

Checking the validity of parentheses in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Nov-2020 06:47:13

2K+ Views

We are required to write a JavaScript function that takes in a string str containing just the characters −'(', ')', '{', '}', '[' and ']'Our function should determine if the input string is valid.An input string is valid if −Open brackets must be closed by the same type of brackets.Open ... Read More

Finding the longest "uncommon" sequence in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Nov-2020 06:45:16

150 Views

We are required to write a JavaScript function that takes in an array of strings. The function should find the longest uncommon subsequence among the strings of the array.By longest uncommon subsequence we mean the longest subsequence of one of these strings and this subsequence should not be any subsequence ... Read More

Difference between first and the second array in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 11:29:27

180 Views

We are required to write a JavaScript function that takes in two arrays of literals. The arrays might contain some identical entries as well.The purpose of our function is to simply find out and return an array of all such elements that exists in the first array but not in ... Read More

Find the closest index to given value in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 11:28:24

414 Views

We are required to write a JavaScript function that takes in an array of numbers as the first input and a single number as the second input.The function should find and return the index of the number from the array which is closest to the number specified by second argument.ExampleThe ... Read More

Using a recursive function to capitalize each word in an array in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 11:27:17

416 Views

We are required to write a JavaScript function that takes in an array of String literals. The function should do the following two things −Make use of recursive approachMake first word of each string element capital.Our function should do this without using extra space for storing another array.For example −If ... Read More

Advertisements