[Geeks for Geeks] Peak element

Peak element

An element is called a peak element if its value is not smaller than the value of its adjacent elements(if they exists).

Given an array arr[] of size N, find the index of any one of its peak elements.

Note: The generated output will always be 1 if the index that you return is correct. Otherwise output will be 0.

Read more
[Geeks for Geeks] Max rectangle

Max rectangle

Given a binary matrix M of size n X m. Find the maximum area of a rectangle formed only of 1s in the given matrix.

Read more
[Geeks for Geeks] Number of Coins

Number of Coins

Given a value V and array coins[] of size M, the task is to make the change for V cents, given that you have an infinite supply of each of coins{coins1, coins2, …, coinsm} valued coins. Find the minimum number of coins to make the change. If not possible to make change then return -1.

Read more
[Geeks for Geeks] k largest elements

k largest elements

Given an array Arr of N positive integers, find K largest elements from the array. The output elements should be printed in decreasing order.

Read more
[Geeks for Geeks] Next Permutation

Next Permutation

Implement the next permutation, which rearranges the list of numbers into Lexicographically next greater permutation of list of numbers. If such arrangement is not possible, it must be rearranged to the lowest possible order i.e. sorted in an ascending order. You are given an list of numbers arr[ ] of size N.

Read more
[Geeks for Geeks] Largest number in K swaps

Largest number in K swaps

Given a number K and string str of digits denoting a positive integer, build the largest number possible by performing swap operations on the digits of str at most K times.

Read more
[Geeks for Geeks] Length of the longest substring

Length of the longest substring

Given a string S, find the length of the longest substring without repeating characters.

Read more
[Geeks for Geeks] Find the number of islands

Find the number of islands

Given a grid of size n*m (n is number of rows and m is number of columns grid has) consisting of ‘0’s(Water) and ‘1’s(Land). Find the number of islands.

Note: An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically or diagonally i.e., in all 8 directions.

Read more
[Geeks for Geeks] Lowest Common Ancestor in a Binary Tree

Lowest Common Ancestor in a Binary Tree

Given a Binary Tree with all unique values and two nodes value, n1 and n2. The task is to find the lowest common ancestor of the given two nodes. We may assume that either both n1 and n2 are present in the tree or none of them are present.

Read more
[Geeks for Geeks] Multiply two strings

Multiply two strings

Given two numbers as strings s1 and s2. Calculate their Product.

Note: The numbers can be negative.

Read more