AmitDiwan has Published 10744 Articles

Checking digit sum of smallest number in the array in JavaScript

AmitDiwan

AmitDiwan

Updated on 27-Feb-2021 17:35:00

226 Views

We are required to write a JavaScript function that takes in an array of numbers as the first and the only argument. The function should first pick the smallest number from the array and then calculate the sum of all the digits of the number.If the digit sum of that ... Read More

Finding gcd of two strings in JavaScript

AmitDiwan

AmitDiwan

Updated on 27-Feb-2021 17:32:38

3K+ Views

In the number system, the Greatest Common Divisor (GCD) of two numbers is that greatest number which divides both the numbers. Similarly, if we apply this concept to strings, the gcd of two strings is the greatest substring (greatest in length) that is present in both the strings.For example −If ... Read More

Finding all valid word squares in JavaScript

AmitDiwan

AmitDiwan

Updated on 27-Feb-2021 17:29:33

261 Views

Word Square:A word square consists of a set of words written out in a square grid, such that the same words can be read both horizontally and vertically.For instance, once valid word square is −H E A R T E M B E R A B U S E R ... Read More

Find Smallest Letter Greater Than Target in JavaScript

AmitDiwan

AmitDiwan

Updated on 27-Feb-2021 17:27:05

411 Views

Suppose we are given an array of sorted characters letters containing only lowercase letters. And given a target letter target.We are required to write a JavaScript function that takes in the array as the first argument and the letter as the second. The function is supposed to find the smallest ... Read More

Counting all possible palindromic subsequence within a string in JavaScript

AmitDiwan

AmitDiwan

Updated on 27-Feb-2021 17:24:49

413 Views

Palindrome Sequence:A string sequence is known as palindrome sequence if it reads the same from front and the back. For instance, 'aba', 'madam, 'did' are all valid palindrome sequences.We are required to write a JavaScript function that takes in a string as the first and the only argument. The string ... Read More

Can array be divided into n partitions with equal sums in JavaScript

AmitDiwan

AmitDiwan

Updated on 27-Feb-2021 17:22:40

230 Views

We 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 function should determine whether there exists a way of distributing the elements of the array arr into num groups such that all ... Read More

Finding n most frequent words from a sentence in JavaScript

AmitDiwan

AmitDiwan

Updated on 27-Feb-2021 17:08:31

1K+ Views

For the purpose of this question, we define a sentence as a string that contains English alphabets and punctuations and a word is a substring of that sentence joined together by whitespaces.We are required to write a JavaScript function that takes in a sentence string, str, as the first argument ... Read More

Checking if an array is sorted lexicographically in reference to some scrambled alphabet sequence in JavaScript

AmitDiwan

AmitDiwan

Updated on 26-Feb-2021 10:02:43

315 Views

We are required to write a JavaScript function that takes in an array of string words as the first argument. The second argument to the function will be a string containing all 26 English lowercase alphabets but in some random scrambled order.The task of our function is to check whether ... Read More

Squaring every digit of a number using split() in JavaScript

AmitDiwan

AmitDiwan

Updated on 26-Feb-2021 10:01:17

216 Views

We are required to write a JavaScript function that takes in a number as the first and the only argument. The function should then square every digit of the number, append them and yield the new number.For example −If the input number is −const num = 12349;Then the output should ... Read More

Calculating time taken to type words in JavaScript

AmitDiwan

AmitDiwan

Updated on 26-Feb-2021 09:59:42

287 Views

Suppose we have a keyword, which instead of the traditional qwerty type key mapping, maps keys simply according to the english alphabetic order i.e., abcde...Before we dive into the problem, we have to make the following two assumptions −Currently our fingertip is placed at index 0, i.e., the key 'aThe ... Read More

Advertisements