Strings and Queries
Strings and Queries
for(int i=0;i<input1;i++) {
if(min>input2[i][0]) {
min=input2[i][0];
}
if(max<input2[i][1]) {
max=input2[i][1];
}
}
int ans=0;
for(int i=min;i<=max;i++) {
int check =0;
for(int j =0;j<input1;j++) {
if(input2[j][0]< i && input2[j][1]>=i) {
check++;
}
}
if(check>ans) {
ans=check;
}
}
return ans;
package pp;
for(int i=0;i<input1;i++) {
if(min>input2[i][0]) {
min=input2[i][0];
}
if(max<input2[i][1]) {
max=input2[i][1];
}
}
int ans=0;
for(int i=min;i<=max;i++) {
int check =0;
for(int j =0;j<input1;j++) {
if(input2[j][0]< i && input2[j][1]>=i) {
check++;
}
}
if(check>ans) {
ans=check;
}
}
return ans;
package pp;
import java.util.Arrays;
}
}
return count;
int input1 = 3;
String[] input2 = {"medium", "easy", "yeasseya"};
System.out.println(numberOfPairs(input1, input2));
package Final;
return result;
}
if (c1 != c2) {
operations++;
}
}
return operations;
}
public static void main(String[] args) {
String S = "abcd";
int lengthS = S.length();
int[][] pairs = {{1, 3}, {2, 4}};
int lengthPairs = pairs.length;
Your friend John is solving a puzzle which has some rules for solving it. He gets
stuck at some point and asks you for help. The puzzle has a string S which consists
of lowercase English alphabets and there are two types of string operations that
you can perform -
1. Delete a character from the string. 2. Change a character to any other character
in the string
You are given P pairs, where each pair has two numbers L and R. A substring of
string S can be formed from pair, where L is the starting index and R is the last
index. For each substring formed out of a pair, you need to find the minimum number
of string operations required to convert it into a palindrome, by rearranging the
characters of the modified substring
Input Specification:
input1: a string S.
input2: an integer denoting the length of the string.