class Solution:
    """
    @param str: the string
    @param k: the length
    @return: the substring with  the smallest lexicographic order
    """

    def minSubStr(self, s):
        ch, index = chr(ord('z') + 1), -1
        for i in range(len(s)):
            if s[i] < ch:
                ch, index = s[i], i
        return ch, index

    def deleteChar(self, s, k):
        # Write your code here.
        if k <= 0:
            return ''

        ch, index = self.minSubStr(s)
        if len(s) - index - 1 >= k - 1:
            return ch + self.deleteChar(s[index + 1:], k - 1)
        else:
            new_k = k - (len(s) - index)
            return self.deleteChar(s[:index], new_k) + s[index:]


if __name__ == '__main__':
    s = Solution()
    print(s.deleteChar("fskacsbi", 2))
