Recently I Got An E-mail From Google That I’ve been selected from the Resume review round To Google’s Online Challenge round. On the 29th Of August, I’ve given That Challenge and face these two problems, which I want to share with all…
A Special String: You Are given a string S consisting of the lowercase Latin alphabet, 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)
- The first line contains an integer T denoting the number of test cases
- The first line of each 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.
1 ≤ T ≤ 5 1 ≤ N ≤ 103 N is Even
1 6 aababc
Change S = ‘d’(1 – based indexing) Change S = ‘d’ New String = ‘aabddc’ Now all Pairs (S[i],S[j]) Satisfy the second condition, S[i] < S[j].
A Special Matrix: You are given an N × N matrix A. The matrix consists of positive integers. In one move, you can apply the following single transformation to the matrix:
Select an arbitrary element of the matrix and increase or decrease it by 1. Each element can be increased or decreased for any arbitrary number of times.
A special number P is a non-negative integer for which the following quadratic equation has at least one negative integer root:
X2 - 2 × P + x = 0
A matrix is called special if at least one of the following conditions is true:
- The matrix has a row with special numbers only.
- The matrix has a column with special numbers only.
Your task is to count the minimum number of moves required to get special matrix A
- The first line contains T denoting the number of test cases.
- The first line of each test case contains an integer N denoting the number of rows and columns.
- Next N lines of each test case contain N integers denoting the initial matrix A.
For each test case, print a single integer in a new line denoting the minimum number of moves required to get a special matrix from the provided matrix. if you have already obtained a special matrix, then print 0.
1 ≤ T ≤ 10 1 ≤ N ≤ 500 1 ≤ A[i][j] ≤ 1011(1 ≤ i ≤ N, 1 ≤ j ≤ N)
1 3 1 2 3 4 5 6 7 8 9
Explanation: Either the first row or third column can be modified to convert the matrix into a special matrix with a minimum number of moves. The first row can be transformed into [1,3,3] by increasing one time the second element of the first row.
- GOCC15: Google SWE Online Coding Challenge Internship 2021
- Google Interview Experience for Internship (Coding Round)
- GOCC14: Google Online Coding Challenge 2020 - New Grad (India)
- GOCC18: Google Online Coding Challenge 2020 - New Grad(India)
- Postman Online Round for Internship
- GOCC14: Google's Online Coding Challenge - New Grad (India)
- MakeMyTrip Interview Experience | Set 5 (Online Coding)
- BrowserStack Interview Experience | Set 7 (Online Coding Questions)
- MakeMyTrip Interview Experience | Set 6 (Online Coding)
- Fiberlink (maas360) Interview Experience | Set 5 (Online Coding Question)
- Tesco Bengaluru Interview Experience | Set 1 (Online Coding Test)
- Microsoft Interview Experience | Set 141 (Off-Campus - Online Coding Test for IDC)
- Atlassian Online Coding Interview Experience
- Lynk Logistics First online round | On-Campus
- SAP Labs First Online Round
- Grofers Interview Experience | Online Round
- Google Online Challenge for Summer Internship 2021
- GOCC15: Google's Online Challenge for Internship (India)
- TCS NQT Coding Questions & How Coding Task Evaluated in TCS NQT
- Cigital Interview Experience (Coding Test Round 1)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.