Skip to content
Related Articles

Related Articles

GOCC18: Google’s Online Coding Challenge
  • Difficulty Level : Basic
  • Last Updated : 14 Dec, 2020

The GOCC18 was held on September 26, 2020, for Goggle 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 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

Sample output

zzzze


Write your Interview Experience or mail it to contribute@geeksforgeeks.org

My Personal Notes arrow_drop_up
Recommended Articles
Page :