
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6710 Articles for Javascript

865 Views
The perimeter of a triangle is the sum of the lengths of its three sides. You can find the perimeter of a triangle using JavaScript by finding the sum of all sides of the triangle, as the perimeter of the triangle refers to the sum of all three sides of the triangle, i.e., perimeter = a + b + c. To find the perimeter of a triangle using JavaScript, we need to write a function that calculates the sum of three sides of a triangle and returns the triangle's perimeter as an output. In this article, we will understand the ... Read More

124 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 the last element of the array to the first position. We will continue this loop for k times to get the rotated array. Finally, we will return the mth element of the rotated array as the result. Approach The approach for finding the mth element after k right rotations of ... Read More

180 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 of an even number of elements, the median will be the average of the two middle values. Approach Given a row-wise sorted matrix, the median can be found by the following approach − Combine all rows into a single sorted array. Find the middle element(s) of the combined array, ... Read More

352 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 rotate the digits and keep track of the highest value obtained until all possible rotations have been evaluated. The maximum value obtained from this process will then be returned as the result. Approach To find the maximum possible value by rotating digits of a given number, follow these steps − ... Read More

410 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 with the maximum product. The algorithm we will be using involves finding the sum of the products of the index and values of the elements, then adding the difference between this sum and the product of the length of the array and the sum of the index values to this ... Read More

158 Views
We will be writing a JavaScript program to find the maximum number of zeros placed consecutively at the start and end of any rotation of a binary string. Our program will take a binary string as input and will return the maximum number of zeros that are placed at the start and end in any rotation of the given string. To solve this problem, we will be using string manipulation techniques to manipulate the input string and find the required output. In the next step, we will be rotating the input string and counting the number of zeros placed at ... Read More

488 Views
In JavaScript, the 2D matrix manipulation involves working with arrays of arrays, often to perform operations on rows or columns. In this example, we focus on finding the maximum value in each row of a matrix. Two methods are demonstrated: using nested loops for step-by-step iteration, and using map() with Math.max() for a more concise, functional approach. Both methods return an array of the maximum values from each row, but the map() approach is more efficient and modern. Different approaches Following are the different approaches to finding maximum element of each row in a matrix − ... Read More

600 Views
To find lexicographically minimum string rotation in Javascript, we will understand two different approaches in this article. A lexicographically minimum rotation of a string is the smallest string that can be obtained by rotating the original string any number of times in lexicographical order. By lexicographical order it means dictionary order such as: a < b, ab < ac. In this article we are having a string. Our task is to write a JavaScript program to find lexicographically minimum string rotation. Example Input: bba All lexicographical order are: bba, bab, abb Output: Smallest lexicographical rotation: abb ... Read More

150 Views
We will be using the JavaScript array sort method and slicing technique to find the k maximum elements of an array in their original order. Firstly, we sort the array in descending order, and then slice it from the beginning to the kth index to obtain the k maximum elements. By preserving the original order of the elements, the significance and context of the data remains intact, making it easier for us to analyze and interpret the results. Approach The approach to find k maximum elements of an array in original order can be described as follows − Create ... Read More

552 Views
A subarray with a sum of 0 is a sequence of contiguous elements within an array where the sum of all elements in that sequence equals zero. Identifying such subarrays is a common problem in data analysis and coding challenges. The prefix sum technique efficiently solves this problem. In this article we will find if there is a subarray with 0 sum using JavaScript. Continuously calculate the prefix sum while traversing the array and use a hash map to store sums seen so far. Check if the current prefix sum ... Read More