AmitDiwan has Published 10744 Articles

Can split array into consecutive subsequences in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 10:30:38

244 Views

ProblemWe are required to write a JavaScript function that takes in an array of sorted integers, arr, as the first and the only argument.Our function should return true if and only if we can split the array into 1 or more subsequences such that each subsequence consists of consecutive integers ... Read More

Converting array into increasing sequence in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 10:30:07

228 Views

Increasing SequenceWe define an array as increasing if arr[i]

Total number of longest increasing sequences in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 10:28:25

824 Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers, arr, as the first and the only argument.Our function is required to find the number of longest increasing subsequences (contiguous or non-contiguous).For example, if the input to the function isInputconst arr = [2, 4, 6, ... Read More

Map Sum Pairs in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 10:27:56

305 Views

ProblemWe are required to implement a MapSum class with insert, and sum methods. For the method insert, we'll be given a pair of (string, integer). The string represents the key and the integer represents the value. If the key already existed, then the original key-value pair will be overridden to ... Read More

Using operations to produce desired results in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 10:27:32

114 Views

ProblemWe are required to write a JavaScript function that takes in an array of exactly 4 numbers, arr, as the first argument and a target as the second argument.Our function need to judge whether the numbers in the array arr could operated through *, /, +, -, (, ) to ... Read More

Forming palindrome using at most one deletion in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 10:27:03

193 Views

ProblemWe are required to write a JavaScript function that takes in a string, str, as the first and the only argument.Our function may delete at most one character from the string str and we are required to check whether we can make it a palindrome doing so.For example, if the ... Read More

Forming the nearest time using current time in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 10:26:37

443 Views

ProblemWe are required to write a JavaScript function that takes in a string, time, that represents time in the "HH:MM" form.Our function is supposed to form the next closest time by reusing the current digits. There is no limit on how many times a digit can be reused.For example, if ... Read More

Can one string be repeated to form other in JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 10:26:00

113 Views

ProblemWe are required to write a JavaScript function that takes in two strings, str1 and str2, as the first and the second argument.Our function should return the minimum number of times we should repeat string str1 so that string str2 is a substring of it. If it is impossible for ... Read More

Finding the most frequent word(s) in an array using JavaScript

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 10:25:33

884 Views

ProblemWe are required to write a JavaScript function that takes in an array, arr, of strings of English lowercase alphabets as the first argument. The second argument to our function is a number, num (num < length of arr).Our function is supposed to return the num most frequent elements in ... Read More

Are bits alternating in integer using JavaScript?

AmitDiwan

AmitDiwan

Updated on 24-Apr-2021 10:24:57

181 Views

ProblemWe are required to write a JavaScript function that takes in an integer, num, as the first and the only argument.Our function should check whether the binary representation of num has alternating bits − namely, if two adjacent bits will always have different values.For example, if the input to the ... Read More

Advertisements