Ravi Ranjan

Ravi Ranjan

About

Hello readers, I am a technical content engineer having expertise in front-end web development and C++.

117 Articles Published

Articles by Ravi Ranjan

Page 2 of 12

JavaScript Program for Mirror of Matrix Across Diagonal

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 524 Views

To write a javascript program for mirror of matrix across diagonal, we will be discussing two approaches with their code examples and explanations. In this article we have a 2D matrix. Our task is to write a JavaScript program that creates a mirror of the matrix across its diagonal. This operation is also known as matrix transpose, where rows become columns and columns become rows. ...

Read More

JavaScript Program for Number of Local Extrema in an Array

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 349 Views

JavaScript Program for the Number of local extrema in an array is a common problem in the field of computer science and data analysis. Local extrema are the peaks and valleys in a sequence of numbers. In this article we are having two arrays, our task is to write a Javascript program for number of local extrema in an array. Local Extrema in Array [1, 2, 3, 2, 1, 4, 5, 6, 5, 4, 3, 2, 1] ...

Read More

JavaScript Program for Block Swap Algorithm for Array Rotation

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 504 Views

To implement block swap algorithm for array rotation, we will be understanding two different approaches. Rotation of the array elements means moving the elements of the given array to either the left or right side by some number of specific positions. Block swap algorithm for array rotation means to rotate the elements of the array by a given number but not using the rotation but the swapping technique. In this article we are having an array and a variable d by which array will be rotated, our task is to write a JavaScript program for block swap algorithm for ...

Read More

JavaScript Program to Efficiently Compute Sums of Diagonals of a Matrix

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 572 Views

In a square matrix, there are two main diagonals: the primary diagonal (left-to-right) and the secondary diagonal (right-to-left). Computing their sums efficiently is a common programming task with practical applications in linear algebra and image processing. In this article, we will explore two JavaScript approaches to calculate diagonal sums: a brute force method using nested loops and an optimized single-loop solution. 3x3 Matrix Diagonals ...

Read More

JavaScript Program for Diagonally Dominant Matrix

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 328 Views

A diagonally dominant matrix is a square matrix where the absolute value of each diagonal element is greater than or equal to the sum of absolute values of all other elements in that row. In this article, we'll write a JavaScript program to check if a given matrix is diagonally dominant. This requires understanding 2D arrays, nested loops, and conditional statements. Diagonally Dominant Matrix Example ...

Read More

JavaScript Program for Maximum and Minimum in a Square Matrix

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 417 Views

To get maximum and minimum in a Square Matrix in JavaScript, we will be discussing two different approaches, their complexities, and example codes. The first approach uses nested loops while the second approach uses Math functions. In this article we are having a 2D square matrix, our task is to write a JavaScript program for maximum and minimum in a square matrix. Problem Statement Input: Matrix: [ [1, 3, 7], [5, 2, 9], [2, 5, 1] ] Output: Maximum ...

Read More

Javascript Program to Count Pairs with Given Sum

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 1K+ Views

To count pairs with given sum is a common problem asked in job interviews and is often used in many real-world applications such as cryptography and data compression. In this article we are having an array and a target sum value, our task is to write a JavaScript program to count pairs with given sum. Array: [1, 2, 3, 5, 6, 7, 9] Target Sum: 8 1 ...

Read More

JavaScript Program to Find Common Elements in Two Sorted Arrays

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 667 Views

To find common elements in two sorted arrays using JavaScript, we will be discussing various approaches. Common element refers to element which is present in both the arrays. First, we will try brute force approach and then we will optimize our code to improve the time complexity. In this article we are having two sorted arrays, our task is to find common elements in two sorted arrays. Users must already know about JavaScript arrays, its function and operations on arrays, loops, searching technique and conditional statement. ...

Read More

Binary Search program in JavaScript

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 877 Views

The binary search algorithm works on the divide and conquer principle as it keeps dividing the array in half before searching. To search for an element in an array using binary search, the array should be sorted. In the sorted array, we find the middle element and compare it with the element that has to be searched, and based on the comparison, we either search in the left sub-array, right sub-array, or return the middle element. In this article, we are given a sorted array of integers, and our task is to search for the given target element ...

Read More

largest string formed by choosing words from a given Sentence as per given Pattern

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 421 Views

To find the largest string formed by choosing words from a given sentence, a user should know about the lexicographically largest string. A lexicographically largest string is a string, when sorted alphabetically, it would appear at the last if we form all possible strings from the selected words. For example: {lion, zebra, apple} will be lexicographically sorted as {apple, lion, zebra}. In this article, we have been given a string and a pattern. Based on this pattern, we have to find the lexicographically largest string matching the given pattern by choosing words from the sentence using C. Here is ...

Read More
Showing 11–20 of 117 articles
« Prev 1 2 3 4 5 12 Next »
Advertisements