Category: Algorithm
Edit Distance program in Javascript
We have 2 strings and we can perform below operations on st1 to make it same as str2. Insert Remove Replace Input: str1 = “cat”, str2 = “cut”Output: 1We can […]
Insertion Sort in Javascript
In last post we have posted about Bubble Sort algorithm in javascript. In this post we will write javascript program on Insertion sort. In Insertion Sort to sort an array […]
Bubble Sort Algorithm in Javascript
Bubble sort is a simple algorithm to sort a unsorted array. We will swap the the elements with the adjacent element. Please find the implementation below. References: https://www.geeksforgeeks.org/bubble-sort/ Also Please […]
Binary Search Program in Javascript
Binary Search is a technique to search a element in an array with efficient time complexity (Ologn) In binary search we divide array into halves and check if middle value […]
Minimum number of jumps to reach end of array in Javascript
Write a function to return the minimum number of jumps to reach the end of the array (starting from the first element). If an element is 0, they cannot move […]
Longest Common Subsequence Program in Javascript
Given two sequences, find the length of longest subsequence present in both of them. A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous. […]
Sort an array according to the order defined by another array in Javascript
Given two arrays A1[] and A2[], sort A1 in such a way that the relative order among the elements will be same as those are in A2. For the elements not […]
Program to print all permutations of a given string In Javascript
Below are the permutations of string ABC.ABC ACB BAC BCA CBA CAB This can be solved using recursive algorithm and most asked question in interviews, Algorithm: BacktrackingTime Complexity: O(n*n!)
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 […]