Given a string of size N and an integer K, the task is to generate a string whose substrings of size K can be concatenated into a given string. Example: Input: str=”abbaaa” K=2Output: abaaDescription:All child strings of the parent string “abaa” of size 2 are “ab”, “ba” and “aa”. Once all of these substrings are concatenated, you can…
For a given n> 0, find different ways to write n to the sum of two or more positive integers. Example: This problem can be solved by the coin change problem, except that in this case, we should iterate 1 to n-1 instead of repeating a specific coin value like the coin change problem. C/C++…
Given a string str. The string may contain lowercase letters, special characters, numbers or even spaces. The task is to check if only the letters present in the string form a palindrome combination, without using any extra spaces. Note: No extra space is allowed to resolve this issue. In addition, the letters present in the string are all lowercase, and the…
An array list represents an ordered collection of objects that can be indexed individually. It’s basically an alternative to arrays. It also allows to dynamically allocate memory, add, search and sort items in the list. ArrayList. The RemoveRange(Int32, Int32) method is used to remove a series of elements from the ArrayList. Properties of the ArrayList class: The…
Linked lists <T> classes exist in the System.Collections.Generic namespace. This generic type allows for quick insertion and deletion of elements. It implements the classic linked list. Each object is assigned individually. In LinkedList, some operations don’t require duplicating the entire collection. But there are many common situations where LinkedList affects performance. Features of the LinkedList…
Given three positive integers L, R, and K. The task is to find all numbers that contain at least one divisor K number in the range [L, R]. Example: Input: L = 5, R = 11, K = 10Output: 3 5, 10 and 11 are such numbers.Input: L = 32, R = 38, K =…
Given a binary tree. Make a modification so that after the modification, it can be traversed in order using only the correct pointers. During modification, you can use both the right and left pointers. Example: Recommended: Try the following {IDE} first, before proceeding with the solution. Method 1 (Recursive) You need to make the right pointer of the…
Given a set of m different positive integers and the value “N”. The problem is to calculate the total number of “N” formed by summing the elements of the array. Duplication and different arrangements are allowed. Example: Method: This method is based on the concept of dynamic programming. Here’s an implementation of the above method. C ++…
Given two strings str1 and str2 and operations below them, operations can be performed on str1. Find out the minimum number of edits (operations) required to convert ‘str1’ to ‘str2’. All of the above operating costs are equal. Example: In this case, what are the sub-issues? The idea is to process all the characters one by one…
Challenge: There are 4 people (A, B, C, and D) who want to cross the bridge at night. AWe take 1 minute to cross the bridge. B takes 2 minutes to cross the bridge. C takes 5 minutes to cross the bridge. D: Take 8 minutes to cross the bridge. They only have a torch,…