Tag: Arrays
Merge two sorted arrays in Javascript
In this blog we are writing program to merge two sorted arrays in javascript. Problem : Given two sorted arrays, merge them into a new array that is also sorted. […]
Find Second largest element in an array in Javascript
This program is to find second largest element in an array in Javascript. This was asked in PaisaBazaar interview and i have solved it perfectly. So i thought to share […]
Program for Stock Buy Sell to Maximize Profit in Javascript
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, […]
Rearrange an array in maximum minimum form in Javascript
In a sorted array of integers, rearrange the array alternately. First element should be the maximum value, second minimum value, third-second max, fourth-second min and so on. Examples Input: arr[] […]
Longest Increasing Subsequence in Javascript
The Longest Increasing Subsequence (LIS) problem is to find the length of the longest subsequence of a given sequence such that all elements of the subsequence are sorted in increasing […]
Minimum number of coins program in Javascript
Input: coins[] = {25, 10, 5}, V = 30 Output: Minimum 2 coins required We can use one coin of 25 cents and one of 5 cents This program can […]
Largest Sum Contiguous Subarray in Javascript
Simple Idea is to use Kadane’s algorithm is to look for all positive contiguous segments of the array. And keep track of maximum sum contiguous segment among all positive segments
Find subarray with given sum in Javascript
Given an unsorted array of nonnegative integers, find a continuous subarray which adds to a given number. Input: arr[] = {1, 4, 20, 3, 10, 5}, sum = 33 Ouptut: […]