AmitDiwan has Published 10740 Articles

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

AmitDiwan

AmitDiwan

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

662 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

174 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

629 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

480 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

745 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

819 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

930 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

268 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

Filtering string to contain unique characters in JavaScript

AmitDiwan

AmitDiwan

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

811 Views

ProblemWe are required to write a JavaScript function that takes in a string str. Our function should construct a new string that contains only the unique characters from the input string and remove all occurrences of duplicate characters.ExampleFollowing is the code − Live Democonst str = 'hey there i am using ... Read More

Advertisements