Javascript Articles

Page 18 of 534

JavaScript Program for Print all triplets in sorted array that form AP

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 279 Views

AP is the arithmetic progression in which the difference between two consecutive elements is always the same. We will print all the triplets in a sorted array that form AP using three approaches: Naive approach, binary search method and two-pointer approach. Introduction to Problem In this problem we are given a sorted array meaning all the elements are in increasing order. We have to find three elements which are part of the array and form an AP. For example − Given array: [1, 5, 2, 4, 3] From the given array we have triplets like [2, ...

Read More

JavaScript Program for Printing Reverse of a Linked List Without Actually Reversing

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 278 Views

Linked lists are linear data structures with their memory not being in a consecutive manner. We will write a complete code in JavaScript with different approaches and examples to understand the process better. Introduction to Problem In the given problem, we are given a linked list and we have to print all of its elements in reverse order, but we don't have to reverse the given linked list. For example − Given linked list: 1 2 3 4 5 6 Result: 6 5 4 3 2 1 We will use two methods ...

Read More

JavaScript Program for Queries to find the maximum sum of contiguous subarrays of a given length in a rotating array

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 250 Views

Rotating array means we will be given a number and we have to move the elements of the array in cyclic order in either the right or left direction. Here we are not specified so we will use the right rotation as the standard and after the given number of rotations, we will return the subarrays with the maximum sum. We will see the code with the proper explanation in the article. Introduction to Problem In this problem, we are given an array that contains the integers and another array that contains the pairs of queries. Each index ...

Read More

JavaScript Program for Quicksort On Singly Linked List

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 409 Views

The singly-linked list is a linear data structure that consists of nodes. Each node contains data and a pointer to the next node, which holds the memory address of the next node since memory allocation for nodes is not continuous. Sorting arranges elements of a data structure like linked lists or arrays in a specific order, typically ascending. In this article, we'll implement the quicksort algorithm on a singly linked list using JavaScript. Introduction to Problem QuickSort is a divide-and-conquer sorting algorithm that uses recursion. It has an average time complexity of O(N * log(N)), making it ...

Read More

JavaScript Program for Range LCM Queries

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 246 Views

LCM stands for the Least Common Multiple, and the LCM of a set of numbers is the smallest positive integer that is divisible by all the numbers in the given set. In this article, we will implement a JavaScript program to handle range LCM queries efficiently. Problem Statement We are given an array of integers and another array of queries. Each query contains a pair of indices representing a range in the original array. For each query, we need to calculate the LCM of all elements within that range. For example, if the array is [1, 2, ...

Read More

JavaScript Program for Range sum queries for anticlockwise rotations of Array by K indices

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 264 Views

Anticlockwise rotation of an array means rotating all the elements of the given array to their left side by the given number of indexes. In this article, we will implement a JavaScript program for range sum queries for anticlockwise rotations of the array by k indices. Introduction to Problem In this problem, we are given an array that will contain some integers and another array that will contain the values in the pairwise form. Each pair will be the number of rotations we need for the current query and after a given number of rotations, we will be ...

Read More

How to Design Digital Clock using JavaScript?

Asif Rahaman
Asif Rahaman
Updated on 15-Mar-2026 4K+ Views

Dealing with time is one of the most common concepts of web developers. Whether to schedule time for the subscription period or schedule email sending requires developers to deal with the time. In this article, we will learn how to design a digital clock using JavaScript. Get The Time On Clicking The Button We can achieve the same operation using multiple logic and codes. First, in this section, we shall learn how to design a digital clock that shows the time when the user clicks on the button. Follow the steps to achieve the step − ...

Read More

JavaScript program for Minimum move to end operations to make all strings equal

Aishwarya Mani Tripathi
Aishwarya Mani Tripathi
Updated on 15-Mar-2026 394 Views

There are many problems that require a certain level of expertise and creativity to solve. One such problem is determining the minimum number of moves required to make all strings equal. In this article, we will explore how to solve this problem using JavaScript programming. First, let's define the problem. Problem Statement Given an array of strings, we need to find the minimum number of moves required to make all strings equal. In a move, we can move the first character of a string to the end of the same string. Example Consider the following array ...

Read More

JavaScript Program for Merging Two Sorted Linked Lists Such That Merged List Is in Reverse Order

Aishwarya Mani Tripathi
Aishwarya Mani Tripathi
Updated on 15-Mar-2026 391 Views

In this tutorial, we will learn about the JavaScript Program for merging two sorted linked lists such that the merged list is in reverse order. We will first understand the problem statement with some examples. Then we will go through a step-by-step approach to solve this problem, including creating a function that takes in two linked lists as arguments and returns the merged list in reverse order. We will also discuss different approaches and their time complexity to help you choose the most efficient solution. Problem Statement We have two linked lists sorted in increasing order and our ...

Read More

JavaScript program for Mean of range in an array

Aishwarya Mani Tripathi
Aishwarya Mani Tripathi
Updated on 15-Mar-2026 630 Views

Given an array of numbers and a range, the goal is to calculate the mean of all the numbers within that range. This problem can be approached in various ways, but in this tutorial, we will explore a simple and efficient solution using JavaScript. Before we begin, let's define what we mean by "mean". In mathematics, the mean (also known as the average) is calculated by adding up all the values in a set of numbers and then dividing the sum by the number of values. In the context of an array, the mean of a range of values ...

Read More
Showing 171–180 of 5,340 articles
« Prev 1 16 17 18 19 20 534 Next »
Advertisements