We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Sorry, I meant the onbe that you posted. Here is my version:
def Mingle(P:List[Char],Q:List[Char]):List[Char] = {
if(P.isEmpty)return List()
return P.head :: Q.head :: Mingle(P.tail,Q.tail)
}
def main(args: Array[String]) {
val P = readLine().toList
val Q = readLine().toList
println(Mingle(P,Q).mkString)
}
Note that I don't use the + operator.
Thanks,
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
String Mingling
You are viewing a single comment's thread. Return to all comments →
Sorry, I meant the onbe that you posted. Here is my version: def Mingle(P:List[Char],Q:List[Char]):List[Char] = { if(P.isEmpty)return List() return P.head :: Q.head :: Mingle(P.tail,Q.tail) }
Note that I don't use the + operator. Thanks,