You are viewing a single comment's thread. Return to all comments →
def matchingStrings(strings: Array[String], queries: Array[String]): Array[Int] = { val lookupTable = strings.groupBy(s => s) queries.foldLeft(Array[Int]())((acc, next) => { val matches = lookupTable.get(next).map(_.length).getOrElse(0) acc :+ matches }) }
Functional style also :D
Seems like cookies are disabled on this browser, please enable them to open this website
Sparse Arrays
You are viewing a single comment's thread. Return to all comments →
Functional style also :D