AmitDiwan has Published 11365 Articles

JavaScript Program to Generate all rotations of a number

AmitDiwan

AmitDiwan

Updated on 15-Mar-2023 15:20:03

297 Views

We will generate all rotations of a number in JavaScript by converting the number into a string, then rotating the characters of the string, and finally converting it back into a number. This process will be repeated for each rotation. We will continuously repeat this process until we have generated ... Read More

JavaScript Program to Generate a matrix having sum of secondary diagonal equal to a perfect square

AmitDiwan

AmitDiwan

Updated on 15-Mar-2023 15:17:28

146 Views

We will write a JavaScript program that generates a matrix with the sum of the secondary diagonal being a perfect square. Our program will use nested loops to traverse the matrix and calculate the sum of the secondary diagonal elements. We will then use the Math.sqrt() method to find the ... Read More

JavaScript Program to Form coils in a matrix

AmitDiwan

AmitDiwan

Updated on 15-Mar-2023 15:15:13

135 Views

We will be using JavaScript to form coils in a matrix. The process involves manipulating the elements of the matrix to create a spiral pattern. This can be achieved by changing the direction of traversal, keeping track of the visited elements, and adjusting the indices accordingly. We will be continuously ... Read More

JavaScript Program to Find the subarray with least average

AmitDiwan

AmitDiwan

Updated on 15-Mar-2023 15:13:18

115 Views

We are going to write a program that will find the subarray with the least average. To do this, we will iterate through the array and keep track of the current subarray and its sum. For each element, we will calculate the average of the current subarray and compare it ... Read More

JavaScript Program to Find the Longest Bitonic Subsequence | DP-15

AmitDiwan

AmitDiwan

Updated on 15-Mar-2023 15:10:30

153 Views

We will be finding the longest bitonic subsequence in each array using dynamic programming. A bitonic subsequence is a sequence which is first increasing, then decreasing. To find the longest bitonic subsequence, we will use a two-step approach. First, we will find the longest increasing subsequence in the given array, ... Read More

JavaScript program to find perimeter of a triangle

AmitDiwan

AmitDiwan

Updated on 15-Mar-2023 15:03:49

434 Views

We will find the perimeter of a triangle by adding the lengths of its three sides. To do this, we will first declare three variables to store the lengths of the sides and then use the addition operator to sum these values and store the result in a fourth variable. ... Read More

JavaScript Program to Find Mth element after K Right Rotations of an Array

AmitDiwan

AmitDiwan

Updated on 15-Mar-2023 15:02:00

66 Views

We are writing a JavaScript program to find the mth element after k right rotations of an array. Firstly, we will take the input for the array, m and k. Then, we will use a loop to perform the right rotations. In each iteration of the loop, we will move ... Read More

JavaScript Program to Find median in row wise sorted matrix

AmitDiwan

AmitDiwan

Updated on 15-Mar-2023 15:00:46

106 Views

We will be describing the process of finding the median in a row-wise sorted matrix using JavaScript. First, we will traverse the matrix to gather all the elements into a single array. Then, we will sort the array to find the middle value, which will be our median. In case ... Read More

JavaScript Program to Find Maximum value possible by rotating digits of a given number

AmitDiwan

AmitDiwan

Updated on 15-Mar-2023 14:59:32

254 Views

We will be writing a program to find the maximum value possible by rotating the digits of a given number. We will be using a loop to break down the number into individual digits and rearrange them in a way that gives us the maximum value. The loop will continuously ... Read More

JavaScript Program to Find maximum value of Sum( i*arr[i]) with only rotations on given array allowed

AmitDiwan

AmitDiwan

Updated on 15-Mar-2023 14:55:41

265 Views

We will be using a mathematical approach to find the maximum value of the sum of the product of the index and the value of the elements in the array. By rotating the array, we can maximize this sum by placing the maximum value of the array at the index ... Read More

Advertisements