Each letter, a-z, is assigned values in the following way: a: 1, b: 2, …, z: 26. You are given string, S, consisting of lowercase English letters and an integer, K. Find the lexicographically minimal string, whose sum is equal to K.

# Find the lexicographically minimal string, whose sum is equal to K

Find the lexicographically minimal string whose sum is K, then why are we provided with S. Please provide the link to the problem if possible…

Please see the Q2 here: https://codingblocks.com/resources/iq-arcesium-nishant/

It was asked in Arcesium

According to me you need to find minimum substring with sum=K. So if you save each character in a 1D array, and then take cummalative sum while iterating over the array. Then for each index i, find an index for ai + K in that array. This will work in O(N) i guess