Company: Google_28thjuly
Difficulty: hard
Lighthouse Flag Broadcast Problem Description Every evening, the keeper of the Saltmere lighthouse raises a sequence of signal flags along the harbour mast. Each flag carries one lowercase letter, and the flags stay in the order in which they were raised. The glow strength of a flag is determined by its letter: a has strength 1, b has strength 2, and so on up to z , which has strength 26. The harbour authority requires the keeper to select exactly k flags from the sequence without changing their original order. The total glow strength of the selected flags must be at least f . Among all selections that satisfy these conditions, find the lexicographically smallest string formed by the selected flags (read in their original order). Complete the function minFlagBroadcastCode(n, s, k, f) , which receives the number of flags n , the string s of flag letters, the number of flags k to select and the minimum total strength f , and returns the lexicographically smallest valid broadcast string.