AmitDiwan has Published 10744 Articles

Can form target array from source array JavaScript

AmitDiwan

AmitDiwan

Updated on 25-Nov-2020 05:13:24

183 Views

We are given an array of distinct integers, let’s say arr, and another array of integer arrays, let say sourceArr.In the sourceArr array, the integers are distinct. We should write a function that forms arr by concatenating the arrays in sourceArr in any order.However, we cannot reorder the integers inside ... Read More

Compare Strings in JavaScript and return percentage of likeliness

AmitDiwan

AmitDiwan

Updated on 25-Nov-2020 05:12:03

1K+ Views

We are required to write a JavaScript function that can compare two strings and return the percentage likeliness of how much they are alike. The percentage will be nothing but a measure of many characters the two strings have in common.If they are completely similar the output should be 100, ... Read More

Check if a string is entirely made of the same substring JavaScript

AmitDiwan

AmitDiwan

Updated on 25-Nov-2020 05:08:14

358 Views

We are required to write a JavaScript function that takes in a string. It should return true or false based on whether the input consists of a repeated character sequence.The length of the given string is always greater than 1 and the character sequence must have at least one repetition.For ... Read More

Insert a number into a sorted array of numbers JavaScript

AmitDiwan

AmitDiwan

Updated on 25-Nov-2020 05:05:49

1K+ Views

We are required to write a JavaScript function that takes in a sorted array of numbers as the first argument and a single number as the second argument.The function should push the number specified as the second argument into the array without distorting the sorting of the elements.We are required ... Read More

Sorting numbers in descending order but with `0`s at the start JavaScript

AmitDiwan

AmitDiwan

Updated on 25-Nov-2020 05:04:15

493 Views

We are required to write a JavaScript function that takes in an array of numbers. The function should sort the array of numbers on the following criteria −---If the array contains any zeros, they should all appear in the beginning.---All the remaining numbers should be placed in a decreasing order.For ... Read More

Calculating the sum of digits of factorial JavaScript

AmitDiwan

AmitDiwan

Updated on 25-Nov-2020 05:03:19

493 Views

We are required to write a JavaScript function that takes in a number. The function should first calculate the factorial of that number and then it should return the sum of the digits of the calculated factorial.For example −For the number 6, the factorial will be 720, so the output ... Read More

Number of letters in the counting JavaScript

AmitDiwan

AmitDiwan

Updated on 25-Nov-2020 05:01:55

361 Views

We are required to write a JavaScript function that takes in a number, say n. The function should count the letters in the number names from 1 to n.For example − If n = 5;Then the numbers are one, two, three, four, five.And the total number of letters are 19, ... Read More

Modify an array based on another array JavaScript

AmitDiwan

AmitDiwan

Updated on 25-Nov-2020 04:57:14

937 Views

Suppose, we have a reference array of phrases like this −const reference = ["your", "majesty", "they", "are", "ready"];And we are required to join some of the elements of above array based on another array so if another array is this −const another = ["your", "they are"];The result would be like ... Read More

Fuzzy Search Algorithm in JavaScript

AmitDiwan

AmitDiwan

Updated on 25-Nov-2020 04:55:12

1K+ Views

We are required to write a JavaScript String function that takes in a search string can loosely checks for the search string in the string it is used with.The function should take this criterion into consideration: It should loop through the search query letters and check if they occur in ... Read More

Longest decreasing subsequence subarray in JavaScript

AmitDiwan

AmitDiwan

Updated on 25-Nov-2020 04:53:54

215 Views

We are required to write a JavaScript function that takes in an array of Integers. The function should return the length of the longest decreasing subsequence from the array.For example −If the input array is −const arr = [5, 2, 5, 4, 3, 2, 4, 6, 7];Then the output should ... Read More

Advertisements