You are viewing a single comment's thread. Return to all comments →
Kotlin solution with O(n)
var editedText = "" val breakerPoint = sqrt(s.length.toDouble()).toInt() val map = mutableMapOf<Int,String>() s.forEachIndexed { index, c -> map[index % (breakerPoint)] = (map[index % (breakerPoint)]?: "") + c } map.values.forEachIndexed { index, s -> editedText += s if (index != map.size - 1) { editedText += " " } }
Seems like cookies are disabled on this browser, please enable them to open this website
Encryption
You are viewing a single comment's thread. Return to all comments →
Kotlin solution with O(n)