Difference between Node require and ES6 import and export
Node.js uses the CommonJS module system to organize code. This means when you want to use code from other files, you use methods like ‘require’. Additionally, Node.js also supports ‘ES6 import and export’ for this purpose. Let us understand in detail....
read more
How to get the first element of an array in PHP?
In this article, we will see how to get access to the first element of an array in PHP, & also understand their implementation through the examples. There are mainly 3 types of arrays in PHP that can be used to fetch the elements from the array:...
read more
Sort an Object Array by Date in JavaScript
To sort an Object Array by Date in JavaScript, we have different approaches. We are going to learn how to sort an Object Array by Date in JavaScript....
read more
Extract unique objects by attribute from array of objects
Given an array of objects and the task is to return the unique object by the attribute....
read more
How to find property values from an array containing multiple objects in JavaScript ?
To find property values from an array containing multiple objects in JavaScript, we have multiple approaches. In this article, we will learn how to find property values from an array containing multiple objects in JavaScript....
read more
Javascript Program for Largest Sum Contiguous Subarray
Write an efficient program to find the sum of contiguous subarray within a one-dimensional array of numbers that has the largest sum....
read more
Javascript Program for Two Pointers Technique
Two pointers is really an easy and effective technique which is typically used for searching pairs in a sorted array.Given a sorted array A (sorted in ascending order), having N integers, find if there exists any pair of elements (A[i], A[j]) such that their sum is equal to X....
read more
Fastest way to duplicate an array in JavaScript
Multiple methods can be used to duplicate an array in JavaScript.The fastest way to duplicate an array in JavaScript is by using the slice() Method. Let us discuss some methods and then compare the speed of execution....
read more
Javascript Program For Stock Buy Sell To Maximize Profit
The cost of a stock on each day is given in an array, find the max profit that you can make by buying and selling in those days. For example, if the given array is {100, 180, 260, 310, 40, 535, 695}, the maximum profit can earned by buying on day 0, selling on day 3. Again buy on day 4 and sell on day 6. If the given array of prices is sorted in decreasing order, then profit cannot be earned at all....
read more
Javascript Program For Finding Subarray With Given Sum – Set 1 (Nonnegative Numbers)
Given an unsorted array of nonnegative integers, find a continuous subarray which adds to a given number. Examples :...
read more
Javascript Program for Third largest element in an array of distinct elements
Given an array of n integers, find the third largest element. All the elements in the array are distinct integers. Example :...
read more
Javascript Program to Find closest number in array
Given an array of sorted integers. We need to find the closest value to the given number. Array may contain duplicate values and negative numbers....
read more