GOCC18: Google’s Online Coding Challenge
The GOCC18 was held on September 26, 2020, for Google SWE New Grad 2021 (India). There were 2 coding questions to attempt, with a 60-minute time limit for completion. Below is the first question of the challenge:
Question1: The cost of a string
Your task is to create a string S considering lowercase English alphabets. You are given an array A of size 26 where A[i] denotes the cost of using the ith Alphabet (consider 1-based indexing). Find lexicographically the largest string S that can be created such that the cost of building the string is exactly W. For example, ‘abc’ is lexicographically smaller than ‘abcd’.
- The first line contains an integer T denoting the number of test cases.
- The first line of each test case contains 26 space-separated integers denoting the costs of characters from ‘a’ to ‘z’.
- The second line of each test case contains an integer W.
Output format: For each test case, print the required string S in a new line.
1 1 1 2 33 4 6 9 7 36 12 58 32 28 994 22 255 47 69 558 544 21 36 48 85 48 58 236
Hey geek! It’s time to become a success story instead of reading them. Check out our most renowned DSA Self Paced Course, now at a student-friendly price and become industry ready. And if you are looking for a more complete interview preparation resource, check out Complete Interview Preparation Course that will prepare you for the SDE role of your dreams!
Feeling prepared enough for your interview? Test your skills with our Test Series that will help you prepare for top companies like Amazon, Microsoft, TCS, Wipro, Google and many more!