Solution in Scala
Semi-cryptic semi-functional :p solution based on votrubac\'s solution.\n\nThe imperative non-functional approach is better and faster. This is just for fun and
Semi-cryptic semi-functional :p solution based on votrubac\'s solution.\n\nThe imperative non-functional approach is better and faster. This is just for fun and for FP fans.\n\n# Code\n```scala\nobject Solution {\n  def isTransformable(s: String, t: String) = {\n    val seed = Array.fill(10)(List.empty[Int])\n    val idx = s.view.map(_-\'0\').zipWithIndex.foldRight(seed) {\n      case ((d, i), idx) => idx(d) ::= i; idx\n    }\n    !t.iterator.map(_-\'0\').exists { d =>\n      idx(d).headOption.map { i =>\n        (0 until d).map(idx).exists(_.headOption.exists(_ < i))        \n      }\n      .tapEach(_ => idx(d) = idx(d).tail)\n      .forall(identity)\n    }\n  }\n}\n```
['Scala']