Found 6685 Articles for Javascript

JavaScript Program for Two Pointers Technique

Aishwarya Mani Tripathi
Updated on 17-Apr-2023 15:51:59

1K+ Views

JavaScript Program for Two Pointers Technique is a commonly used algorithmic approach to solve various problems that require linear time complexity. This technique is widely used to find a solution for problems that involve searching, sorting, or manipulating arrays, strings, or linked lists. The approach works by maintaining two pointers, one starting from the beginning and the other starting from the end of the data structure, and then iterating through them towards each other until a solution is found. In this tutorial, we will explore the concept of the Two Pointers Technique and how it can be implemented using ... Read More

JavaScript program for the third largest element in an array of distinct elements

Aishwarya Mani Tripathi
Updated on 17-Apr-2023 15:50:48

432 Views

In this tutorial, we will explore different ways to solve the problem using JavaScript. We will discuss various strategies and approaches that can be used to find the third largest element, and we will provide step-by-step explanations for each method. By the end of this tutorial, readers should have a solid understanding of how to approach this problem and find the third largest element in an array of distinct elements using JavaScript. Before we start, let's first understand what an array is. An array is a group of elements, and each element in the array is assigned a unique index. ... Read More

JavaScript program for Swapping Nodes in A Linked List Without Swapping Data

Aishwarya Mani Tripathi
Updated on 17-Apr-2023 15:50:02

220 Views

JavaScript program for Swapping Nodes in A Linked List Without Swapping Data is a familiar problem in web development that involves rearranging the order of nodes in a linked list. A linked list is a data structure that consists of nodes, each containing a piece of data and a reference to the next node in the list. In this article, we will learn a complete tutorial about swapping nodes in a linked list without swapping data using JavaScript. So let’s get started by defining swapping nodes first and then we move ahead in this tutorial. So, Keep learning! Swapping Nodes ... Read More

JavaScript Program for Sorting a Linked List of 0s, 1s, And 2s

Aishwarya Mani Tripathi
Updated on 17-Apr-2023 15:47:44

128 Views

In this tutorial, we will learn the JavaScript program for sorting a linked list of 0s, 1s, and 2s. Sorting algorithms are essential for any programming language, and JavaScript is no exception. Sorting a linked list of 0s, 1s, and 2s is a common problem that developers encounter in coding interviews and real-world applications. So, let's dive in and explore how to sort a linked list of 0s, 1s, and 2s using JavaScript programming. What is sorting? Sorting is the process of arranging elements in a specific order, either ascending or descending. It is a fundamental operation in computer science ... Read More

JavaScript program for Sort the given matrix

Aishwarya Mani Tripathi
Updated on 17-Apr-2023 15:45:51

161 Views

Sorting a given matrix using JavaScript is a fundamental operation in programming. Sorting is the process of arranging the elements of a collection or matrix in a particular order. It is essential to make searching and other operations more efficient. In this article, we will discuss how to sort a given matrix using the JavaScript programming language. Example Given a n x n matrix in a specific order known as the "strict order". In the strict order, each row of the matrix must be sorted in ascending order, and for any row i where 1 matrix[i + 1][j]) ... Read More

JavaScript program for Size of the Subarray with Maximum Sum

Aishwarya Mani Tripathi
Updated on 17-Apr-2023 15:44:08

206 Views

JavaScript program for the Size of the Subarray with Maximum Sum is a common problem in the field of programming, especially in web development. The problem statement involves finding the contiguous subarray within a given one-dimensional array of integers which has the largest sum. This is also known as the maximum subarray problem. Solving this problem can be extremely useful in a variety of applications, such as financial analysis, stock market prediction, and signal processing. In this article, we will see the algorithm and the implementation of the size of the subarray with maximum sum using JavaScript. We will begin ... Read More

JavaScript program for Shortest Un-Ordered SubarrayJavaScript program for Shortest Un-Ordered Subarray

Aishwarya Mani Tripathi
Updated on 17-Apr-2023 15:41:46

51 Views

The problem statement requires finding the shortest un-ordered subarray in an array of integers. In other words, we need to identify the smallest subarray in which the elements are not sorted in ascending or descending order. This problem can be solved through various approaches, but in this article, we will discuss a simple and efficient solution using JavaScript. So first we will start by defining what an un-ordered Subarray is, then understand the problem statement in detail and then proceed to explain the step-by-step solution using examples and code snippets. By the end of this article, you will have ... Read More

JavaScript Program for Searching an Element in a Linked List

Aishwarya Mani Tripathi
Updated on 17-Apr-2023 15:38:56

301 Views

A linked list is a linear data structure where each element, also known as a node, contains a data value and a reference to the next node in the list. One common operation on a linked list is searching for a specific element. This involves traversing the list and comparing each node's data value to the target element until a match is found. Here is an example of a linked list that we will be working with throughout this article − 10 -> 20 -> 30 -> 40 -> null In this linked list, each node contains a value, and ... Read More

Explain about IIFEs in JavaScript

Nikesh Jagsish Malik
Updated on 17-Apr-2023 15:44:45

146 Views

In the world of JavaScript, there are various techniques and patterns that developers use to write efficient, maintainable code. One such powerful programming technique is the Immediately Invoked Function Expression (IIFE). In this article, we'll dive into IIFEs, their benefits, and how to implement them using different approaches. We'll also explore some practical examples to help you understand their applications in real-world scenarios. Algorithm The algorithm for implementing IIFEs in JavaScript can be summarized as follows − Create a function expression. Wrap the function expression in parentheses. Add an additional set of parentheses immediately after the function expression to ... Read More

JavaScript Program for Search an element in a sorted and rotated array

Aishwarya Mani Tripathi
Updated on 20-Apr-2023 15:29:15

266 Views

When an array is sorted in ascending order and then rotated by some pivot point, it becomes challenging to search for an element using traditional search algorithms. As a developer, you need to find an efficient solution to this problem. In this article, we will guide you through the process of writing a JavaScript program to search for an element in a sorted and rotated array. We will explain the underlying logic and provide you with a step-by-step approach to implementing this program. Problem Statement Before we begin, let's understand the problem statement. We have a sorted array that has ... Read More

Advertisements