AmitDiwan has Published 10744 Articles

Finding the nth palindrome number amongst whole numbers in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 08:37:23

526 Views

ProblemWe are required to write a JavaScript function that takes in number n. Our function should return the nth palindrome number if started counting from 0.For instance, the first palindrome will be 0, second will be 1, tenth will be 9, eleventh will be 11 as 10 is not a ... Read More

Smallest number formed by shuffling one digit at most in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 08:34:59

214 Views

ProblemWe are required to write a JavaScript function that takes in a positive number n. We can do at most one operation −Choosing the index of a digit in the number, remove this digit at that index and insert it back to another or at the same place in the ... Read More

Finding life path number based on a date of birth in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 08:32:10

458 Views

Life Path NumberA person's Life Path Number is calculated by adding each individual number in that person's date of birth, until it is reduced to a single digit number.ProblemWe are required to write a JavaScript function that takes in a date in “yyyy-mm-dd” format and returns the life path number ... Read More

Longest possible string built from two strings in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 08:29:53

521 Views

ProblemWe are required to write a JavaScript function that takes in two strings s1 and s2 including only letters from ato z.Our function should return a new sorted string, the longest possible, containing distinct letters - each taken only once - coming from s1 or s2.ExampleFollowing is the code − Live ... Read More

Adding and searching for words in custom Data Structure in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 08:27:39

181 Views

ProblemWe are required to design a data structure in JavaScript that supports the following two operations −addWord, which adds a word to that Data Structure (DS), we can take help of existing DS like arrays or any other DS to store this data, search, which searches a literal word or ... Read More

Counting number of 9s encountered while counting up to n in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 08:25:36

391 Views

ProblemWe are required to write a JavaScript function that takes in a number n. Our function should count and return the number of times we will have to use 9 while counting from 0 to n.ExampleFollowing is the code − Live Democonst num = 100; const countNine = (num = 0) ... Read More

Finding a number, when multiplied with input number yields input number in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 08:23:26

141 Views

ProblemWe are required to write a JavaScript function that takes in a positive integer n written as abcd... (a, b, c, d... being digits) and a positive integer pwe want to find a positive integer k, if it exists, such as the sum of the digits of n taken to ... Read More

Finding the sum of floors covered by an elevator in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 08:20:06

136 Views

ProblemWe are required to write a JavaScript function that takes in an array that represents the floor numbers at which a building lift stopped during an interval of time.From that data, our function should return the count of total number of floors covered by the lift in that time.ExampleFollowing is ... Read More

Decrypting source message from a code based on some algorithm in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 08:18:39

162 Views

ProblemWe are required to write a JavaScript function that takes in a decrypted message and returns its source message.All we know is the algorithm used to encrypt that message.And the algorithm is −Reverse the message string.Replace every letter with its ASCII code in quotes (A to '65', h to '104' ... Read More

Sum array of rational numbers and returning the result in simplest form in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 08:17:05

181 Views

ProblemWe are required to write a JavaScript function that takes in an array of exactly two subarrays with two numbers each.Both the subarrays represent a rational number in fractional form. Our function should add the rational numbers and return a new array of two numbers representing the simplest form of ... Read More

Advertisements