AmitDiwan has Published 10744 Articles

Maximum Product of Two Numbers in a List of Integers in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Jan-2021 06:48:39

269 Views

We are required to write a JavaScript function that takes in an array of integers as the first and the only argument.The function should find the maximum product that can be achieved multiplying any two elements of the array. The condition for us is that we have to do this ... Read More

Check if a string is repeating in itself in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Jan-2021 06:44:45

819 Views

We are required to write a JavaScript function that takes in a string as the first and the only argument.The function should detect if the string is a repetition of a same set of characters or not.If it is a repetition of the same set of characters then we should ... Read More

Counting the number of palindromes that can be constructed from a string in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Jan-2021 06:42:58

341 Views

We are required to write a JavaScript function that takes in a string of characters as the first argument, say str, and a number, say num, as the second argument.The function should count the number of palindrome strings all exactly of length num can be constructed from the given string ... Read More

Returning acronym based on a string in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Jan-2021 06:38:41

1K+ Views

We are required to write a JavaScript function that takes in a string of characters as the only argument.The function should build and return the acronym based on the string phrase provided as input.While constructing the acronym the function should take only those words into consideration that starts with an ... Read More

Counting largest numbers in row and column in 2-D array in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Jan-2021 06:36:48

431 Views

We are required to write a JavaScript function that takes in a two-dimensional array of integers as the only argument.The task of our function is to calculate the count of all such integers from the array that are the greatest both within their row and the column.The function should then ... Read More

Sorting only columns of a 2-D array in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Jan-2021 06:34:51

790 Views

We are required to write a JavaScript function that takes in a two-dimensional array of integers as the only argument.The function should sort the elements present at the column of the array in increasing or decreasing order.For example −If the input array is −const arr = [    [6, 2, ... Read More

Substring in infinitely extended string in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Jan-2021 06:32:06

159 Views

We are required to write a JavaScript function that takes in a string of characters as the first argument and a start index and end index as second and third argument respectively. The function should find, had that string, provided as the first argument, been extended forever by appending the ... Read More

Checking if one string can be achieved from another with single tweak in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Jan-2021 07:11:59

94 Views

We are required to write a JavaScript function that takes in two strings of characters lets call them str1 and str2.The function should check whether we can form str2 from str1 by deleting exactly one character from str1. If we can do so the function should return true, false otherwise.For ... Read More

Sorting Integers by The Number of 1 Bits in Binary in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Jan-2021 07:10:16

512 Views

We are required to write a JavaScript function that takes in an array of integers as the only argument.The function should sort the integers present in the array in increasing order based on the 1s present in their binary representation. If two or more numbers have the same number of ... Read More

Swapping even and odd index pairs internally in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Jan-2021 07:08:39

520 Views

We are required to write a JavaScript function that takes in an array of literals as the first and the only argument.Our function should swap each consecutive even index with each other, and swap each consecutive odd indexes with each other.The function should do these swappings in place.For example −If ... Read More

Advertisements