Found 6683 Articles for Javascript

Remove elements from singly linked list in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 16:33:07

399 Views

In the given problem statement we are presented with a singly linked list and our task is to remove one element from the list. So we will discuss this operation step by step below. What is a singly Linked List ? A singly linked list consists of a series of nodes. It is a type of data structure. In this every node contains a value or we can say data and the list to the next node in the sequence. The first node in the list is called the head and the last node in the list points ... Read More

Find all pairs that sum to a target value in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 15:42:24

1K+ Views

Our aim in the given problem statement is to find all the possible pairs which sum to a given target value with the help of Javascript. So we can solve this problem with the help of some built-in functions of Javascript. Understanding the Problem The given problem is stating that we have given an array and a target value and our task is to find all the possible pairs that sum to the target value. For example suppose we have an array like [6, 5, 4, 3, 2, 1] and the target value is 6 so the possible ... Read More

isSubset of two arrays in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 18:27:39

237 Views

Our goal in the above problem statement is to use Javascript functionalities and determine whether or not the given arrays are subsets of each other. So using loops we can fix this problem. Understanding the problem The problem description specifies that we have to identify that the given array is a subset of another array. Or we have to check that all of the items in the second array are present in the first array. For example, suppose we have an array like ['a', 'b', 'c', 'd', 'e'] and a second array ['b', 'd', 'e']. So when we ... Read More

Algorithm to add binary arrays in JavaScript

AmitDiwan
Updated on 11-Aug-2023 16:10:01

510 Views

In this problem statement, our target is to add two binary arrays with the help of Javascript. So we will break down the problem step by step to ensure understanding. What is the Binary array ? A binary array is an array that represents a binary number. In a binary number system we have only two possible digits, 0 and 1. The binary array will have the elements which can only be 0s and 1s. Every item in the array will represent a bit of the binary number. For example we have a binary array [1, ... Read More

Chunking array within array in JavaScript

Nikitasha Shrivastava
Updated on 11-Aug-2023 16:57:55

203 Views

In this problem statement, our target is to get the chunking array within the array with the help of Javascript functionalities. So basically we will divide an array into smaller arrays. What is the meaning of Chunking array within an array ? Chunking an array means arranging the array items in smaller subarrays of the same size. Or we can say that chunking an array within an array refers to the process of dividing the large size array into the smaller subarrays or chunks. So the items of the original array are arranged together into the nested arrays ... Read More

Function for counting frequency of space separated elements in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 17:55:26

163 Views

In this problem statement, our target is to create a function for counting frequency of space separated elements with the help of Javascript functionalities. Understanding the Problem The given problem is stating that we have given a space separated elements and our task is to count the frequency of space separated items. So we will provide some strings with some space separated items and assign a result array to see the counts of the frequency of such items. For example if we have a string with space separated items like “Car, Bike, Car, Bicycle, Bike”, in this ... Read More

Sorting according to weights of numbers in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 16:55:33

888 Views

In this problem statement, our target is to sort the given array of numbers according to the weights of numbers with the help of Javascript. At the beginning we will write a function that calculates the weights of the numbers and then sort them with another function. Understanding the Problem We have to sort the provided numbers according to their weights. As a result we will have an array of numbers. A weight of the number is defined as the sum of its own digits. For example: suppose we have an array like [19, 11, 12, 15]. We ... Read More

JavaScript program to convert positive integers to roman numbers

Nikitasha Shrivastava
Updated on 14-Aug-2023 18:30:42

422 Views

In the given problem we have to change the given positive number (the number should be an integer number) into the corresponding roman number and then implement the code using Javascript. Understanding the problem We have to write a Javascript program to generate the roman number representation of given integer numbers in the given problem statement. The code should accept a positive integer as input and will be able to transform the integer into its equivalent roman number. For example: suppose we have an integer number 5 so here 5 is the input integer number and the ... Read More

How to reverse a string using only one variable in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 18:19:30

151 Views

In this problem statement, our target is to print the reverse string using only one variable and implement the solution with the help of Javascript. So we can solve this problem with the help of loops in Javascript. Understanding the problem The given problem is stating that we have given a string to which we have to reverse the string. In simple terms we can say that if we have the string “Hello World”, the reverse of this string will be “dlroW ,olleH”. Logic for the given problem In order to reverse the given ... Read More

Shortest distance between objects in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 16:50:13

394 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

Advertisements