Prabhdeep Singh

Prabhdeep Singh

161 Articles Published

Articles by Prabhdeep Singh

Page 11 of 17

JavaScript Program to check idempotent matrix

Prabhdeep Singh
Prabhdeep Singh
Updated on 20-Apr-2023 222 Views

An idempotent matrix is a square matrix that has the same number of rows and columns and when we multiply the matrix by itself the result will be equal to the same matrix. We will be given a matrix and we have to find that whether it is an idempotent matrix or not. Mathematically − If the given matrix ix M, then of M to be an idempotent matrix is should follow the property − M*M = M Multiplication of Matrix Multiplication of a matrix with another matrix produces another matrix and if the given matrix is the square ...

Read More

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

Prabhdeep Singh
Prabhdeep Singh
Updated on 14-Apr-2023 250 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
Prabhdeep Singh
Updated on 14-Apr-2023 230 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
Prabhdeep Singh
Updated on 14-Apr-2023 384 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
Prabhdeep Singh
Updated on 14-Apr-2023 231 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 Printing Reverse of a Linked List Without Actually Reversing

Prabhdeep Singh
Prabhdeep Singh
Updated on 14-Apr-2023 263 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
Prabhdeep Singh
Updated on 14-Apr-2023 259 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

JavaScript Program for Maximum equilibrium sum in an array

Prabhdeep Singh
Prabhdeep Singh
Updated on 14-Apr-2023 1K+ Views

The equilibrium sum of the given array is the sum at a particular point or index of the array after which the subarray has the total sum equal to the sum of the subarray starting from the 0th index to the current index (including the current index). We will see the examples and the code implementations in JavaScrript with the different approaches. Introduction to Problem We are given a single array in which we have to find a point from which the total sum of the elements that are present on the left side (including the current index element) is ...

Read More

JavaScript Program for Maximum difference between groups of size two

Prabhdeep Singh
Prabhdeep Singh
Updated on 14-Apr-2023 182 Views

In this program, we are given an array of integers of even length as we know here we have to make groups of two. We have from that groups using elements of an array, we have to choose two groups among them in order to find the maximum difference between that two groups and we have to return that maximum difference which is going to see in the article below. Introduction to Problem In the given problem we have to find the Maximum difference between groups of size two. It means we have given an array of even length and ...

Read More

JavaScript Program to check if the matrix is lower Triangular

Prabhdeep Singh
Prabhdeep Singh
Updated on 13-Apr-2023 179 Views

A matrix can be defined as a 2D array that stores elements in it and mathematically it stores the numbers in it. A Lower triangular matrix is a squared matrix that has the same number of rows and columns and all the elements that are present above the main diagonal passing from the first cell (present at the top-left) towards the last cell (present at the bottom-right) are zero. We will implement a proper code with explanation and discussion over time and space complexity. Example Input 1: mat = [ [ 1, 0, 0, 0], [ 2, ...

Read More
Showing 101–110 of 161 articles
« Prev 1 9 10 11 12 13 17 Next »
Advertisements