Nikitasha Shrivastava

Nikitasha Shrivastava

163 Articles Published

Articles by Nikitasha Shrivastava

Page 9 of 17

Shortest distance between objects in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 16-Aug-2023 635 Views

In this problem we have to calculate and find the shortest distance between two given objects in Javascript. So we will write a function to do this operation and also we will see its time and space complexity. We must consider the positions and coordinates of the objects in some way. Understanding the Problem The problem says to find the shortest path between the two given objects. So we will use two coordinates. And define a function which will have four parameters. These parameters will represent the x and y coordinates of the two objects. Inside the function ...

Read More

Shift strings Circular left and right in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 16-Aug-2023 1K+ Views

The main objective for the problem statement is to perform a circular shift on the strings in Javascript. The circular shifts can be left shirt or right shift. And implement this solution in Javascript. Understanding the Problem The problem at hand is to shift the strings circularly left and right with the help of Javascript functionalities. Circular shifting means we have to move the characters of the given string in a circular manner in which the characters that are to be shifted beyond the boundaries of the string and it should reappear at the opposite end. ...

Read More

Retrieve key and values from object in an array JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 16-Aug-2023 8K+ Views

In the given problem we are required to retrieve the key and values from an object in an array with the help of Javascript. So here we will retrieve the keys and values from an object in an array with the help of two methods provided by the object class in Javascript. Understanding the Problem Statement The problem statement is to retrieve the keys and values from a given object in an array with the help of Javascript. So in Javascript the object is a collection of properties in which every property is a key and value pair. ...

Read More

Remove duplicate items from an array with a custom function in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 16-Aug-2023 492 Views

In this problem statement our aim is to write an algorithm to remove duplicate items from an array with a function with the help of Javascript functionalities. Understanding the problem statement In the above problem statement we have to create a function by which we can accept an array as a parameter and give a new array to store the unique items from the given input array and without including the identical values. For example - suppose we have an array as [0, 0, 2, 2, 3, 3] so after removing the duplicate numbers we will have ...

Read More

Pick out numbers from a string in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 16-Aug-2023 240 Views

In the given problem we are required to find out the numbers from a given string with the help of Javascript functionalities. So we will use regular expressions and some predefined functions of Javascript. Understanding the Problem The problem at hand is to find the numbers from the given string in Javascript. This task can be useful sometimes. To accomplish this task we will use regular expressions and also some string manipulation functions of Javascript. So in simple terms we will be given a string in this string there will be some integer or other type of number ...

Read More

Partial sum in array of arrays JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 16-Aug-2023 323 Views

In the given problem statement our task is to get the partial sum in an array of arrays with the help of Javascript functionalities. So we will calculate the sum of rows and give the result. Understanding the Problem The problem at hand is to compute the partial sum of an array of arrays. So first understand what an array of arrays is! Array of arrays means each item represents an array itself. For example see the below array of arrays: [ [11, 12, 13], [14, 15, 16], [17, 18, 19] ] The partial sum at ...

Read More

Parse and balance angle brackets problem in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 16-Aug-2023 1K+ Views

In the given problem statement we have to find whether the angle brackets in the code are balanced or not with the help of Javascript functionalities. So for solving this problem we will use a stack based approach using Javascript methods. What is a Stack-based Approach ? The stack-based approach is an algorithmic technique which involves using a data structure called stack. So the stack is a collection of items which supports two main operations: push and pop. Push operation adds an item to the top of the stack and pop removes the top item from the stack. ...

Read More

Pair whose sum exists in the array in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 16-Aug-2023 336 Views

In this article we will see how to find a pair of items in an array which has sum equals to a specific target number. So we will use JavaScript to implement the algorithm. Understanding the Problem The problem at hand is to find the pair of numbers in the array whose sum is equal to the given target value. And the target value should also be there in the array. Or we can say that we have to identify pairs (a, b) where a + b = c and c is also present in the array. ...

Read More

Non-negative set subtraction in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 16-Aug-2023 419 Views

In the given problem statement we are presented with two arrays which contain integer values. So our aim is to find the non negative set subtraction from the two arrays. And implement the solution in Javascript. We can perform this task using the Set object and forEach method. What are the Set object and forEach method in Javascript ? Set object in Javascript The Set is an object in Javascript which is a built in data Structure introduced in ES6. This allows us to store the unique values of any type. The values can be primitive values or ...

Read More

Maximum sum of n consecutive elements of array in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 16-Aug-2023 1K+ Views

In the given problem statement our aim is to find the maximum sum of n consecutive items of array with the help of Javascript functionalities. So for solving this problem we will use basic Javascript functionalities and produce the maximum sum. Understanding the Problem The problem at hand is to find the maximum sum of n consecutive items in the array. This process will involve identifying a continuous subarray of length n within the given array which has the highest possible sum. For example suppose we have an array as [1, 2, 4, 7, 3, 5] so that ...

Read More
Showing 81–90 of 163 articles
« Prev 1 7 8 9 10 11 17 Next »
Advertisements