Found 6710 Articles for Javascript

How to Design Digital Clock using JavaScript?

Asif Rahaman
Updated on 17-Apr-2023 15:27:08

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 − First, create a ... Read More

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

Prabhdeep Singh
Updated on 14-Apr-2023 17:15:00

210 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 given a ... Read More

JavaScript Program for Range LCM Queries

Prabhdeep Singh
Updated on 14-Apr-2023 17:11:10

183 Views

LCM stands for the lowest common multiple and the LCM of a set of numbers is the lowest number among all the numbers which are divisible by all the numbers present in the given set. We will see the complete code with an explanation for the given problem. In this article, we will implement the JavaScript program for a range of LCM queries. Introduction to Problem In this problem, we are given an array that will contain integers and another array queries that will contain pairwise numbers representing the range from the given array we have to calculate the LCM ... Read More

JavaScript Program for Quicksort On Singly Linked List

Prabhdeep Singh
Updated on 14-Apr-2023 17:10:12

330 Views

The Singly-linked list is a linear data structure that consists of nodes. Each node contains the data and the pointer to the next node which contains the memory address of the next node because the memory assigned to each node is not continuous. Sorting is a technique by which we make all the elements of a particular data structure such as a linked list, array, vector, etc in a properly sorted manner in either increasing or decreasing order (if not specified in increasing order). We will see the proper code and the explanation in this article. Introduction to Problem ... Read More

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

Prabhdeep Singh
Updated on 14-Apr-2023 17:08:08

188 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 of the ... Read More

JavaScript Program for Queries for rotation and Kth character of the given string in constant time

Prabhdeep Singh
Updated on 14-Apr-2023 17:06:10

216 Views

Rotation of the given string means moving the characters of the given string in clockwise or anticlockwise manner by some indexes. Here, we will implement a JavaScript program for queries for rotation and kth character of the given string in the constant time. In this article we will implement the proper code and explain each step. Introduction to Problem In the given problem, we are given by a string which contains some characters in it. We are given by some limited queries and each query contains two numbers or integers. First integer represents the number of times we have to ... Read More

JavaScript Program to Cyclically Rotate an Array by One

Prabhdeep Singh
Updated on 10-Jan-2025 10:35:20

412 Views

To cyclically rotate an array by one means shifting the value present at each index to their left or right by one. In this article, we are having an array and our task is to write a JavaScript program to cyclically rotate an array by one. Users must be familiar with JavaScript loops and array operations. Example Input: arr= [ 1, 2, 3, 4, 5, 6 ] Output: Left rotation: [ 2, 3, 4, 5, 6, 1 ] Right rotation: [ 6, 1, 2, 3, 4, 5 ] Approaches to Cyclically ... Read More

JavaScript Program for Products of ranges in an array

Prabhdeep Singh
Updated on 04-Dec-2024 22:05:47

221 Views

We will be given an array and we have to answer some queries related to the given range that is from a given starting index to the ending point or index we have to return the product of the elements in that range. We will see some approaches in this article to implement the above problem in JavaScript with the explanation. Introduction to Problem We are given an array and some queries, in each query we will be given some ranges by indicating the first and the last index of the range and we have to answer the product of ... Read More

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

Prabhdeep Singh
Updated on 14-Apr-2023 17:03:55

208 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 to print the given linked list ... Read More

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

Prabhdeep Singh
Updated on 14-Apr-2023 17:01:10

217 Views

AP is the arithmetic progression in which the difference between two consecutive elements is always the same. We will print all the triplet 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 by a sorted array meaning all the elements are in the increasing form. We have to find the 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 two triplets: 1 2 ... Read More

Advertisements