Open In App

GOCC14: Google Online Coding Challenge 2020 – New Grad (India)

The Google online challenge 2020 for university undergraduates 2021 batch was held on August 22, 2020. Before this round, some shortlisting was done based on your resume.

The test was conducted on HackerEarth platform. The test consisted of two coding questions and the time allotted was 60 minutes. My set of questions are mentioned below.



Find the maximum amount you can get if you perform zero or more such operations optimally. 

Note : 



Example: 

abppprrr  (string S)  
5 4       (value of X and Y )

Output:

15

Explanation : 

Here, S=”abppprrr” 

X= 5, Y=4.

Remove substrings are mentioned :

Remove “pr”, new string S=”abpprr”.

Remove “pr”, new string S=”abpr”.

Remove “pr”, new string S=” “.

In total, we removed pr 3 times, so total score is 3*X + 0*Y = 3*5 =15.

A subsequence is a sequence that can be derived by deleting some or no elements from the sequence without changing the order of remaining elements. 

Example: 

5 6           ( size of A array and B array)
1 2 3 4 5     ( A array )
2 5 6 4 9 12  ( B array )

Output: 

3

Explanation: We need to add 3 numbers in B such that A will become subsequence of B. 

We added 1 at the start of B and elements 3, 4 between 2 and 5. Now array B becomes [1, 2, 3, 4, 5, 6, 4, 9, 12] and A is a subsequence of B.

Article Tags :