[Geeks for Geeks] Longest Arithmetic Progression

Longest Arithmetic Progression

Given an array called A[] of sorted integers having no duplicates, find the length of the Longest Arithmetic Progression (LLAP) in it.

Read more
[Geeks for Geeks] Knight Walk

Knight Walk

Given a square chessboard, the initial position of Knight and position of a target. Find out the minimum steps a Knight will take to reach the target position.

Note:

The initial and the target position co-ordinates of Knight have been given accoring to 1-base indexing.

Read more
[Geeks for Geeks] Number of Provinces

Number of Provinces

Given a graph with V vertices. Find the number of Provinces.
Note: A province is a group of directly or indirectly connected cities and no other cities outside of the group.

Read more
[Geeks for Geeks] Longest Palindromic Subsequence

Longest Palindromic Subsequence

Given a String, find the longest palindromic subsequence.

Read more
[Geeks for Geeks] Form a palindrome

Form a palindrome

Given a string, find the minimum number of characters to be inserted to convert it to palindrome.

For Example:

  • ab: Number of insertions required is 1. bab or aba
  • aa: Number of insertions required is 0. aa
  • abcd: Number of insertions required is 3. dcbabcd
Read more
[Geeks for Geeks] Pots of Gold Game

Pots of Gold Game

Two players X and Y are playing a game in which there are pots of gold arranged in a line, each containing some gold coins. They get alternating turns in which the player can pick a pot from one of the ends of the line. The winner is the player who has a higher number of coins at the end. The objective is to maximize the number of coins collected by X, assuming Y also plays optimally.

Return the maximum coins X could get while playing the game. Initially, X starts the game.

Read more
[Geeks for Geeks] Minimum times A has to be repeated such that B is a substring of it

Minimum times A has to be repeated such that B is a substring of it

Given two strings A and B. Find minimum number of times A has to be repeated such that B is a Substring of it. If B can never be a substring then return -1.

Read more
[Geeks for Geeks] Find an Replace in String

Find an Replace in String

Given a string S on which you need to perform Q replace operations.
Each replacement operation has 3 parameters: a starting index i, a source word x and a target word y. The rule is that if x starts at position i in the original string S, then we will replace that occurrence of x with y. If not, we do nothing.

Note: All these operations occur simultaneously. It’s guaranteed that there won’t be any overlap in replacement: for example, S = “abc”, indexes = [0,1], sources = [“ab”, “bc”] is not a valid test case.

Read more
[Geeks for Geeks] Generate Parentheses

Generate Parentheses

Given an integer N representing the number of pairs of parentheses, the task is to generate all combinations of well-formed(balanced) parentheses.

Read more
[Geeks for Geeks] Repeated String Match

Repeated String Match

Given two strings A and B, find the minimum number of times A has to be repeated such that B becomes a substring of the repeated A. If B cannot be a substring of A no matter how many times it is repeated, return -1.

Read more