## makemytrip Interview Questions

- 0of 0 votes
You are given a string S consisting of lowercase English letters denoting different types of candies. A substring of a string S is a string S' that occurs in S. For example, "bam" is a substring of "babammm". Each candy costs 1 unit. You can pick some continuous candies such that you can create a palindrome of length K by using some or all picked candies. Your task is to find the minimum cost to create a palindrome of length K.

Input Format:

First line contains string S.

Next line contains an integer T denoting the number of test cases.

Next T lines contain a single integer K.

Output Format:

For each test case, print minimum cost as mentioned above. If you cannot create a palindrome of length K then, simply print -1.

Constraints:

Constraints:

1≤|S|≤10^5

1≤T≤10

1≤K≤10^5

Sample Input

babammm

2

2

5

Sample Output

2

5

Explanation

Test Case 1: You can pick candies denoted by "mm" and create a palindrome of size 2. So the cost will be 2 units.

Test Case 2: You can pick candies denoted by "babam" and rearrange them, "bamab", to create a palindrome of size 5. So the cost will be 5 units.

- 0of 0 votes
Write a function which will return a char from a given encoded string from given index without decoding string. e.g. from “a2bc3d4” ( means “aabcbcbcdddd” ) and index value is 7 means function should return c without decoding original string ?

- 0of 0 votes
find out the subset of an array of continuous positive numbers from a larger array whose sum of of the elements is larger in comparision to other subset. eg: {1,2 5 -7, 2 5} .The two subarrays are {1,2,5} {2,5} and the ans is {1,2, 5} as its sum is larger than{2,5}

- 0of 0 votes
Given two classes C1 and C2 which are almost same.(remember not exactly same).

You want to choose best among these classes so that it can be use as key in hashmap.

What question will you ask regarding two classes C1 and C2.