Getting a weird error where the string method replaceAll isn’t being recognized as a function.
Please correct the unit testing.
The code solution is correct, but when I used custom input “abc”, the expected result is “ac”. The code output is “ab”, which is correct.
def smallest_string(s: str) → str:
# WRITE YOUR BRILLIANT CODE HERE
n = len(s)
stack = [s]
flag = True
for i in range(1,n):
if flag and len(stack) > 0 and s[i]< stack[-1]:
flag = False
if name == ‘main’:
s = input()
res = smallest_string(s)