Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Front End Technology Articles
Page 144 of 652
JavaScript Program for Finding Intersection Point of Two Linked Lists
In this tutorial, we will discuss two approaches to finding the intersection point of two linked lists in JavaScript. The first approach uses nested loops, and the second approach uses the difference of nodes technique which works in linear time. We will be given two linked lists that may intersect at some point. The intersection point is where both lists share the same node reference (not just the same value). After the intersection point, all subsequent nodes are identical in both lists. Problem Statement Given two linked lists, we need to find the node where they intersect. ...
Read MoreJavaScript Program to Find a triplet that sum to a given value
In this article, we will learn to find three numbers in an array that add up to a given sum value using JavaScript. We are going to write a JavaScript program to find a triplet that sums up a given value. This program will make use of nested loops to iterate over the input array and check for the existence of a triplet with a sum equal to the given value. We'll present two different approaches and analyze their implementations. Sorting and Two-Pointer Technique The first approach uses sorting and the two-pointer technique to solve the problem efficiently. ...
Read MoreJavaScript Program for Searching an Element in a Linked List
To search for an element in a linked list, we need to go through each node one by one and check if its value matches the target element. If we find the element, we return its position in the list. If not, we return a message saying the element is not found. In this article, our task is to implement a JavaScript program that searches for a specific element in a linked list and returns its position if found, or a message if it is not present. Example Let's look at the below examples: Linked ...
Read MoreJavaScript Program for Left Rotation and Right Rotation of a String
To implement left rotation and right rotation of a string, we can use various approaches. Left rotation means moving characters counter-clockwise by a given number of positions, while right rotation means moving characters clockwise by a given number of positions. In this article we have a string and a value of k by which we will rotate the string. Our task is to write a JavaScript program for left rotation and right rotation of a string. Example Input: String str = "apple"; k = 3 Output: Left Rotation: "leapp" Right Rotation: "pleap" Approaches ...
Read MoreJavaScript program to generate all rotations of a number
In this article, we will learn to generate all rotations of a number in JavaScript. A rotation involves moving the first digit to the end of the number, creating all possible circular arrangements of the digits. Problem Statement Given a number, we need to generate all possible rotations of its digits. A rotation is defined as moving the first digit to the end of the number. Input: 123 All Rotations: 123 (original number) 231 (first rotation: move 1 to the end) 312 (second ...
Read MoreJavaScript program to count triplets with sum smaller than a given value
In this article, we will learn to count triplets with a sum smaller than a given value in JavaScript. Triplets in an array whose sum is less than a provided number is a popular problem in competitive coding and algorithm design. Problem Statement Given an array of integers and a target sum, we need to find the number of triplets (a, b, c) where the sum of three elements is less than the given value. Input: const arr = [5, 1, 3, 4, 7]; const sum = 12; Output: 4 ...
Read MoreJavaScript Program to Find Perimeter of a Triangle
The perimeter of a triangle is the sum of the lengths of its three sides. You can find the perimeter of a triangle using JavaScript by calculating the sum of all sides, where perimeter = a + b + c. To find the perimeter of a triangle using JavaScript, we need to write a function that adds the three side lengths together. In this article, we will understand the perimeter formula and implement practical examples. Understanding the Perimeter Formula The formula for the perimeter of a triangle is straightforward. The perimeter equals the sum of all three ...
Read MoreJavaScript Program to Find Area and Perimeter of Rectangle
To find the area and perimeter of a rectangle in JavaScript, we use the basic formulas for rectangle calculations. The area of a rectangle is the multiplication of its length by its breadth, and the perimeter is the sum of all four sides. In this article, we'll understand the formulas and implement practical JavaScript examples to calculate rectangle area and perimeter. Understanding the Formulas The formulas for rectangle calculations are straightforward: Area = length × breadth Perimeter = 2 × (length + breadth) ...
Read MoreJavaScript Program to Find the Lost Element from a Duplicated Array
To find the lost element from a duplicated array in JavaScript, we will be discussing various approaches. Prerequisites to solve this problem include understanding of JavaScript arrays, loops, Set object, and binary search. In this article we have two arrays where one array is a duplicate of the other with one missing element. Our task is to find the lost element from the duplicated array in JavaScript. Problem Statement Given two arrays where the second array is missing exactly one element from the first array, we need to identify that missing element. Input: array1 = ...
Read MoreJavaScript Program for Counting Frequencies of Array Elements
Counting frequencies of array elements means determining how many times each element appears in an array. This is a common programming task useful for data analysis, statistics, and various algorithms. JavaScript provides multiple approaches to solve this problem efficiently. In this article, we'll explore five different methods to count element frequencies in JavaScript. Each approach has its own advantages - some prioritize simplicity, others performance, and some leverage built-in methods or external libraries. Approaches to Count Array Elements Frequencies Here are the five approaches we'll cover, each with detailed explanations and complete working examples: ...
Read More