Techno Blender
Digitally Yours.
Browsing Tag

Substrings

Maximize value of Binary String in K steps by performing XOR of Substrings

#include <bits/stdc++.h>#define ll long longusing namespace std;  void addZeros(string& str, int n){    for (int i = 0; i < n; i++) {        str = "0" + str;    }}  string getXOR(string a, string b){          int aLen = a.length();    int bLen = b.length();              if (aLen > bLen) {        addZeros(b, aLen - bLen);    }    else if (bLen > aLen) {        addZeros(a, bLen - aLen);    }          int len = max(aLen, bLen);          string res = "";    for (int i = 0; i < len; i++) {        if (a ==…

Maximize product of length of Palindromic Substrings of length at least K

Given a string S and a positive integer K, The task is to maximize the product of the length of non-overlapping palindromic substrings each of… Read More The post Maximize product of length of Palindromic Substrings of length at least K appeared first on GeeksforGeeks. Given a string S and a positive integer K, The task is to maximize the product of the length of non-overlapping palindromic substrings each of… Read More The post Maximize product of length of Palindromic Substrings of length at least K appeared first on…

Maximum bitwise OR on of any two Substrings of given Binary String

View Discussion Improve Article Save Article Like Article View Discussion Improve Article Save Article Like Article Given a binary string str, the task is to find the maximum possible OR value of any two substrings of the binary string str.Examples:Input: str = “1110010”Output: “1111110”Explanation: On choosing the substring “1110010” and “11100” we get the OR value as “1111110” which is the maximum value.Input: str = “11010”Output: “11111”Explanation: On choosing the substring “11010” and “101” we get the OR…

Split Parenthesis Sequence into maximum valid Substrings

View Discussion Improve Article Save Article Like Article View Discussion Improve Article Save Article Like Article Given a String S which contains balanced Parentheses Brackets ( i.e ‘(‘ and ‘)’ ), we need to split them in such a way that they form the maximum number of balanced groups.Examples:Input:  S = “()()(()())()”Output:  (), (), (()()), ()Input:  S = “()()”Output:  (), ()Input:  S = “()()(())”Output:  (), (), (())Approach: To solve the problem follow the below idea:We need to declare two variables, one to…

Count Substrings having at least one occurrence of all first K characters of English alphabet

Given a string S of size N and a positive integer K. The given string only consists of the first K English lowercase alphabets. The… Read More The post Count Substrings having at least one occurrence of all first K characters of English alphabet appeared first on GeeksforGeeks. Given a string S of size N and a positive integer K. The given string only consists of the first K English lowercase alphabets. The… Read More The post Count Substrings having at least one occurrence of all first K characters of English alphabet…