## Check if an array is Wave Array

Given an array of N positive integers. The task is to check if the array is sorted in wave form. Examples: Input: arr[] = {1,… Read More »

Given an array of N positive integers. The task is to check if the array is sorted in wave form. Examples: Input: arr[] = {1,… Read More »

Given N works numbered from 1 to N. Given two arrays D1[] and D2[] of N elements each. Also, each work number W(i) is assigned… Read More »

Given a string consisting only of two lowercase characters and and two numbers and . The task is to print the lexicographically smallest permutation of… Read More »

Consider a two player coin game where each player gets turn one by one. There is a row of even number of coins, and a… Read More »

Given two lists that contains cost prices CP[] and selling prices SP[] of products respectively. The task is to maximize the profit by selling at-most… Read More »

Given an array of list of commands U(Up), D(Down), L(Left) and R(Right) and initial cell position (x, y) in a matrix. Find the final cell… Read More »

Given positive integers N, L, and R, we have to find the maximum value of N ⊕ X, where X ∈ [L, R]. Examples: Input… Read More »

Below are the steps for finding MST using Kruskal’s algorithm 1. Sort all the edges in non-decreasing order of their weight. 2. Pick the smallest… Read More »

We have discussed Prim’s algorithm and its implementation for adjacency matrix representation of graphs. As discussed in the previous post, in Prim’s algorithm, two sets… Read More »

Given a pile of chocolates and an integer ‘k’ i.e. the number of iterations, the task is to find the number of chocolates left after… Read More »

Given an array of n elements and an integer K, the task is to find the subarray with minimum value of ||a[i] + a[i +… Read More »

Given an array of positive integers. The task is to choose a pair of elements from the given array such that they represent the length… Read More »

Given an array of N positive integers and Q queries consisting of an integer K, the task is to print the length of the longest… Read More »

Given an array containing N integers. The task is to find the sum of the elements of the contiguous subarray having the smallest(minimum) sum. Examples:… Read More »

Given two arrays of size N, and two numbers X and Y, the task is to maximize the sum by considering the below points: Pick… Read More »