AmitDiwan has Published 10744 Articles

Kit-Kat array in JavaScript

AmitDiwan

AmitDiwan

Updated on 03-Mar-2021 08:34:54

161 Views

We are required to write a JavaScript function that takes in a natural number, num, as the first argument and two natural numbers m and n as the second and third argument. The task of our function is to return an array that contains all natural numbers from 1 to ... Read More

Finding nth digit of natural numbers sequence in JavaScript

AmitDiwan

AmitDiwan

Updated on 03-Mar-2021 08:10:01

590 Views

Natural Number Sequence:1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12...This sequence extended infinitely is known as natural number sequence.We are required to write a JavaScript function that takes in a number, num, as the first and the only argument. The function should find and return the ... Read More

Finding the sum of two numbers without using '+', '-', '/', '*' in JavaScript

AmitDiwan

AmitDiwan

Updated on 03-Mar-2021 08:06:18

927 Views

We are required to write a JavaScript function add() that takes in two numbers m and n. The function should, without using the four basic arithmetic operations add the two numbers taken as input and return the sum.ExampleThe code for this will be − Live Democonst m = 67, n = ... Read More

Beautiful Arrangement of Numbers in JavaScript

AmitDiwan

AmitDiwan

Updated on 03-Mar-2021 08:03:14

374 Views

Beautiful Arrangement:Suppose we have num integers from 1 to num. We define a beautiful arrangement as an array that is constructed by these num numbers successfully if one of the following is true for the ith position (1 ≤ i ≤ N) in this array −The number at the ith ... Read More

Contiguous subarray with 0 and 1 in JavaScript

AmitDiwan

AmitDiwan

Updated on 03-Mar-2021 07:58:04

295 Views

Problem:We are required to write a JavaScript function that takes in a binary array, arr, (an array that only consists of 0 or 1). Our function should return the length of the contiguous subarray from the array that consists of the same number of 1 and 0.For example, if the ... Read More

Forming the longest word in JavaScript

AmitDiwan

AmitDiwan

Updated on 03-Mar-2021 07:49:42

290 Views

ProblemWe are required to write a JavaScript function that takes in a random English alphabet string, str, as the first argument and an array of strings, arr, as the second argument.The task of our function is to try deleting some characters from the string str and check which longest word ... Read More

Subarray sum with at least two elements in JavaScript

AmitDiwan

AmitDiwan

Updated on 03-Mar-2021 07:47:25

193 Views

ProblemWe are required to write a JavaScript function that takes in an array of Integers, arr, as the first argument and a single Integer, target as the second and first argument. Our function should check whether there exists a continuous subarray of size at least 2 that sums up to ... Read More

Finding the longest substring uncommon in array in JavaScript

AmitDiwan

AmitDiwan

Updated on 03-Mar-2021 07:44:53

205 Views

SubsequenceFor the purpose of this problem, we define a subsequence as a sequence that can be derived from one sequence by deleting some characters without changing the order of the remaining elements. Any string is a subsequence of itself and an empty string is a subsequence of any string.ProblemWe are ... Read More

Implementing a Binary Search Tree in JavaScript

AmitDiwan

AmitDiwan

Updated on 03-Mar-2021 07:43:09

4K+ Views

Tree Data StructureA tree is a collection of nodes connected by some edges. Conventionally, each node of a tree holds some data and reference to its children.Binary Search TreeBinary Search tree is a binary tree in which nodes that have lesser value are stored on the left while the nodes ... Read More

Determining rank on basis of marks in JavaScript

AmitDiwan

AmitDiwan

Updated on 03-Mar-2021 07:41:00

872 Views

ProblemWe are required to write a JavaScript function that takes in an array, arr, of numbers as the only argument.The array basically consists of the marks scored by some students, based on the array of marks, our function should prepare and return an array of ranks which should contain the ... Read More

Advertisements