Skip to content
Related Articles
Open in App
Not now

Related Articles

GOCC18: Google’s Online Coding Challenge

Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 16 Aug, 2021
Improve Article
Save Article

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’.

Input format:

  • 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.

Sample input

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

Sample output

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!