Kth Character
Practice
3.3 (9 votes)
Basic programming
Basics of implementation
Easy
Implementation
String manipulation
Problem
62% Success 23497 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a string $$S$$ of lowercase alphabets. Now you need to remove all the instances of exactly one type of character such that the new string that is formed is lexicographically smallest across all the other strings that can be formed in a similar way.

For example: Let the string $$S$$ be "appleap"

  • If you remove all instances of 'a' then the string formed will be : pplep
  • If you remove all isntances of 'p' then the string formed will be : alea
  • If you remove all intsances of 'l' then the string formed will be : appeap
  • If you remove all instances of 'e' then the string formed will be : applap

So among all the newly formed strings , alea is lexicographically smallest string. 

Note : Lexicographically smallest means the string that would appear before all the strings if they were arranged in the order of words appearing in a dictionary.

Input
First line contains a string $$S$$ as input

Output
Print the lexicographically smallest string that can be formed using the process above

Constraints
$$1 \le |S| \le 10^3$$ where $$|S|$$ is the length of string
The string $$S$$ will contain atleast two distinct characters.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
836 votes
Tags:
Ad-HocSimulationEasyMathematicsOpenApprovedMathamatics
Points:20
58 votes
Tags:
ArraysEasyMath
Points:20
38 votes
Tags:
ApprovedData StructuresEasyImplementationOpen