Google Online Coding challenge (2025 SWE Intern Online Assesment questions)
Anonymous User
522

Google Online Coding challenge (2025 SWE Intern Online Assesment questions):
Q1:Maximum Subarray of Zeros
Given an array of non-negative integers, you can perform the following operations:
Operation 1: Reduce the value of the element by 1.
Operation 2: Change the value of the element to 0.

You are also given three integers: N, X, Y.
N is the length of the array.
You can perform operation 1 at most X times.
You can perform operation 2 at most Y times.

Output the length of the maximum subarray of zeros that can be formed under the given constraints.

Q2) Palindromic Subtree String
Given a tree rooted at vertex 1, where each vertex i corresponds to an alphabet C[i], and (n-1) edges of the tree as vertex pairs (u,v), you are to answer q queries. Each query consists of a vertex u. For each query, you need to perform the following operations:

  1. Initialize an empty string s.
  2. Perform the make_string(u) operation.

The make_string operation:
make_string(u){
for each vertex v which is a child of vertex u: {
make_string(v);
}
s += C[u] ; }

Output 1 if the string s obtained after performing make_string(u), is a palindrome. Otherwise, output 0.

Constraints:
Q is approximately 2 * 10^6
N is approximately 2 * 10^5

Comments (3)