Find strings that end with a given suffix
Given a set of strings S and a string P, the task is to print all strings from the set with the suffix P. Examples:...
read more
CSES solution-Repeating Substring
A repeating substring is a substring that occurs in two (or more) locations in the string. Your task is to find the longest repeating substring in a given string....
read more
Finding absolute difference of sums for each index in an Array
Given an array arr[] of size N, find a new array ans[] where each index i represents the absolute difference between the sum of elements to the left and right of index i in the array arr. Specifically,  ans[i] = |leftSum[i] – rightSum[i]|, where leftSum[i] is the sum of all elements to the left of index i and rightSum[i] is the sum of all elements to the right of index i....
read more
Split a String into two Substring such that the sum of unique characters is maximum
Given a string str, the task is to partition the string into two substrings such that the sum of unique characters of both substrings is the maximum possible....
read more
Minimum count of prefixes and suffixes of a string required to form given string
Given two strings str1 and str2, the task is to find the minimum number of prefixes and suffixes of str2 required to form the string str1. If the task is not possible, return “-1”....
read more
Longest subarray of non-empty cells after removal of at most a single empty cell
Given a binary array arr[], the task is to find the longest subarray of non-empty cells after the removal of at most 1 empty cell....
read more
Remove an element to minimize the LCM of the given array
Given an array arr[] of length N ? 2. The task is to remove an element from the given array such that the LCM of the array after removing it is minimized.Examples:...
read more
Ukkonen’s Suffix Tree Construction – Part 3
This article is continuation of following two articles: Ukkonen’s Suffix Tree Construction – Part 1 Ukkonen’s Suffix Tree Construction – Part 2...
read more
Length of longest subarray whose sum is not divisible by integer K
Given an array arr[] of size N and an integer k, our task is to find the length of longest subarray whose sum of elements is not divisible by k. If no such subarray exists then return -1.Examples:...
read more
Minimize difference between maximum and minimum array elements by removing a K-length subarray
Given an array arr[] consisting of N integers and an integer K, the task is to find the minimum difference between the maximum and minimum element present in the array after removing any subarray of size K....
read more
Minimum cost to make Array equal by increment/decrementing elements
Given an array, arr[], and the cost array cost[], the task is to find the minimum cost to make all the array elements equal by incrementing or decrementing the element at any index by 1. The cost of the increment or decrement operation for the element at index i is the cost[i]....
read more
Count of all possible numbers not exceeding M having suffix N
Given two positive integers N and M, the task is to find the count of all possible numbers in the range [1, M], having suffix as N....
read more