Longest Repeated Subsequence

The problem “Longest Repeated Subsequence” states that you are given a string as an input. Find out the longest repeated subsequence, that is the subsequence that exists twice in the string. Example aeafbdfdg 3 (afd) Approach The problem asks us to find out the longest repeated subsequence in the string. …

Read moreLongest Repeated Subsequence

Difference Array | Range update query in O(1)

You are given an integer array and two types of queries, one is to add a given number in a range and the other to print the whole array. The problem “Difference Array | Range update query in O(1)” requires us to perform the range updates in O(1). Example arr[] …

Read moreDifference Array | Range update query in O(1)

Delete Nth node from the end of the given linked list

Problem Statement The problem “Delete Nth node from the end of the given linked list”  states that you are given a linked list with some nodes. And now you need to remove nth node from the end of the linked list. Example 2->3->4->5->6->7 delete 3rd node from last 2->3->4->6->7 Explanation: …

Read moreDelete Nth node from the end of the given linked list

Find all pairs (a, b) in an array such that a % b = k

Problem Statement The problem “Find all pairs (a, b) in an array such that a % b = k” states that you are given an array of integers and an integer value called k. The problem statement asks to find out the pair in such a way that that x …

Read moreFind all pairs (a, b) in an array such that a % b = k

Check if any two intervals overlap among a given set of intervals

Problem Statement The problem “Check if any two intervals overlap among a given set of intervals” states that you are given some set of intervals. Each interval consists of two values, one is starting time and the other is ending time. The problem statement asks to check if any of …

Read moreCheck if any two intervals overlap among a given set of intervals

Smallest Palindrome after Replacement

Problem Statement In the “Smallest Palindrome after Replacement” problem we have given the input string contains lower case alphabets characters and dots(.). We need to replace all dots with some alphabet character in such a way that the resultant string becomes a palindrome. The palindrome should be lexicographically smallest. Input …

Read moreSmallest Palindrome after Replacement