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:...
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....
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....
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....
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”....
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....
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:...
This article is continuation of following two articles:
Ukkonen’s Suffix Tree Construction – Part 1
Ukkonen’s Suffix Tree Construction – Part 2...
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:...
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....
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]....
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....