You are viewing a single comment's thread. Return to all comments →
Scala, using ScanLeft:
ScanLeft
object Solution { import scala.io.StdIn.{readInt, readLine} def main(args: Array[String]): Unit = (1 to readInt).map(_ => rotateAll(readLine)).foreach(println) def rotateAll(s: String): String = (1 to s.length).scanLeft(s){ case (s, _) => rotate1(s) }.tail.mkString(" ") def rotate1(s: String): String = s.tail.foldRight(List(s.head))(_ :: _).mkString }
Seems like cookies are disabled on this browser, please enable them to open this website
Rotate String
You are viewing a single comment's thread. Return to all comments →
Scala, using
ScanLeft
: