AmitDiwan has Published 10744 Articles

Creating a binary spiral array of specific size in JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 12:02:34

193 Views

ProblemWe are required to write a JavaScript function that takes in a number n. Our function should construct and return an array of N * N order (2-D array), in which the 1s take all the spiralling positions starting from [0, 0] and all the 0s take non-spiralling positions.Therefore, for ... Read More

Change the case without using String.prototype.toUpperCase() in JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 11:59:35

636 Views

ProblemWe are required to write a JavaScript function that lives on the prototype object of the string class.This function should simply change case of all the alphabets present in the string to uppercase and return the new string.ExampleFollowing is the code − Live Democonst str = 'This is a lowercase String'; ... Read More

Preparing numbers from jumbled number names in JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 11:57:55

156 Views

ProblemSuppose the following number name string −const str = 'TOWNE';If we rearrange this string, we can find two number names in it 2 (TWO) and 1 (ONE).Therefore, we expect an output of 21We are required to write a JavaScript function that takes in one such string and returns the numbers ... Read More

Sum of all positives present in an array in JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 11:54:20

2K+ Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers (positive and negative). Our function should calculate and return the sum of all the positive numbers present in the array.ExampleFollowing is the code − Live Democonst arr = [5, -5, -3, -5, -7, -8, 1, 9]; ... Read More

Even index sum in JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 11:52:45

606 Views

ProblemWe are required to write a JavaScript function that takes in an array of integers. Our function should return the sum of all the integers that have an even index, multiplied by the integer at the last index.const arr = [4, 1, 6, 8, 3, 9];Expected output −const output = ... Read More

Python Program to Find if Undirected Graph contains Cycle using BFS

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 11:50:55

440 Views

When it is required to find the sum of all the nodes of a tree, a class is created, and it contains methods to set the root node, add elements to the tree, search for a specific element, and add elements of the tree to find the sum and so ... Read More

Python Program to Find All Connected Components using BFS in an Undirected Graph

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 11:50:37

721 Views

When it is required to find the sum of all the nodes of a tree, a class is created, and it contains methods to set the root node, add elements to the tree, search for a specific element, and add elements of the tree to find the sum and so ... Read More

Python Program to Find All Nodes Reachable from a Node using BFS in a Graph

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 11:50:18

781 Views

When it is required to find the sum of all the nodes of a tree, a class is created, and it contains methods to set the root node, add elements to the tree, search for a specific element, and add elements of the tree to find the sum and so ... Read More

Python Program to Display the Nodes of a Tree using BFS Traversal

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 11:49:49

891 Views

When it is required to display the nodes of a tree using the breadth first search traversal, a class is created, and it contains methods to set the root node, add elements to the tree, search for a specific element, perform ‘bfs’ (breadth first search) and so on. An instance ... Read More

Python Program to Find the Sum of All Nodes in a Binary Tree

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 11:49:29

240 Views

When it is required to find the sum of all the nodes of a tree, a class is created, and it contains methods to set the root node, add elements to the tree, search for a specific element, and add elements of the tree to find the sum and so ... Read More

Advertisements