Skip to content
Related Articles
GOCC15: Google’s Online Challenge for Internship (India)
• Last Updated : 14 Oct, 2020

I came to know about the opportunity through https://careers.google.com/jobs/results/ Google’s website. Applied for the same with my resume. After two weeks got a mail Invite participating in the coding round. The mail had a unique ID and got the passkey(for login) on the day of the coding round1 (29th Aug 2020). The slot was open from 15:00 to 17:00 IST.

A coding round was conducted on the HackerEarth platform. The test duration was 60 minutes consisting of two coding questions, every 30 points. I partially solved 2nd one, the solution didn’t suffice for test cases with large inputs.

A Special String: You are given a string S consisting of lowercase Latin alphabets a-z. Find the minimum number of characters that must be changed to make S special. A string S is said to be special if and only if for all (S[i] , S[j] ) where (1 ≤ i ≤ N/2) and (N/2 + 1 ≤ j ≤ N) one of the following condition is true

• S[i] > S[j]
• S[i] < S[j]
• S[i] = S[j]

S[i] represents the ith character of string S (1 based Indexing ).

Input Format:

• The first line contains an integer T denoting the number of test cases.
• The first line of each test case contains an integer N denoting the length of S.
• The second line of each test case contains a string S.

Output format: Print an integer denoting the minimum number of changes required for each test case in a new line.

Constraints

1 ≤ T ≤ 5

1 ≤ N ≤ 10

N is even

Example :

```Input:  1
6
aababc
Output: 2
```

Explanation: Change S = ‘d’ (1 based indexing) Change S = ‘d’ New string = ‘aabddc’ Now all pair (S[i],S[j]) satisfy the second condition, S[i] < S[j]

Generating Sequence: You are given two strings A of length N and B of length M. These strings contain lowercase English alphabets. You are also given an integer K. You can change the character of x string A to any other characters y. The cost of this conversion is abs( ASCII(x)- ASCII(y) ). Find the minimum cost required such that the length of the longest common subsequence (LCS) of A and B is at least K.

Note:

• A subsequence of A string can be obtained by deleting zero or more characters in A.
• The longest common subsequence of two strings of A and B is a subsequence of A and B and has the maximum length among all strings that are a subsequence of A and B that would be multiple subsequences for two provided strings for example an LCS of vera and eats is ea.

Input Format:

• The first line contains an integer T denoting the number of test cases for each test case.
• The first line of each test case contains three space-separated integers N, M, and K.
• The next line of each test case contains a string A.
• The next line of each test case contains a string B.

Output format: For each test case, print the minimum cost required in a new line.

Constraints

1 ≤ T ≤ 10

1 ≤ N, M ≤ 200

0 ≤ K ≤ min( N, M )

Example:

```Input:  2
5 4 3
abcba
acyx
3 3 3
abc
abc
Output: 22
0
```

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon and Microsoft Test Serieses.

My Personal Notes arrow_drop_up