scala solution with span
scala\nobject Solution {\n  def smallestString(s: String): String =\n    lazy val (t0,d0) = s.span(_ == \'a\')\n    lazy val (t1,d1) = d0.span(_ > \'a\')\n    i
```scala\nobject Solution {\n  def smallestString(s: String): String =\n    lazy val (t0,d0) = s.span(_ == \'a\')\n    lazy val (t1,d1) = d0.span(_ > \'a\')\n    if(d0.isEmpty) (t0.init :+ \'z\').mkString\n    else (t0 ++ t1.map(c => (c-1).toChar) ++ d1).mkString\n}\n```
['Scala']