Company: HashedIn_19sep
Difficulty: medium
Remove K Characters to Get Smallest String Problem Description You are given a string S consisting of lowercase English letters and an integer k. Your task is to remove exactly k characters from S (you may choose any k characters, not necessarily consecutive) in order to obtain the lexicographically smallest possible string. The relative order of the remaining characters must be preserved. Determine the resulting string after removing k characters. Input: S : A string of lowercase English letters. Its length n satisfies 1 ≤ n ≤ 10 5 . k : An integer representing the exact number of characters to remove from S . It satisfies 0 ≤ k < n . Output: A string which is the lexicographically smallest string achievable by removing exactly k characters from S while preserving the order of the remaining characters. The output should be of length n - k . Examples Example 1: Input: S = "bcabc", k = 2 Output: "abc" Explanation: Removing 2 characters from "bcabc" results in "abc". Example