题解 | #ZOJ#
ZOJ
https://www.nowcoder.com/practice/7557d470617c464f9200d93acf721471
m=input() res={"Z":0,"O":0,"J":0} for i in range(len(m)): if m[i]=="Z": res["Z"]+=1 if m[i]=="O": res["O"]+=1 if m[i]=="J": res["J"]+=1 ans="" while res["J"]>0 or res["Z"]>0 or res["O"]>0: if res["Z"]>0: ans+="Z" res["Z"]-=1 if res["O"]>0: ans+="O" res["O"]-=1 if res["J"]>0: ans+="J" res["J"]-=1 print(ans)