Skip to content

Instantly share code, notes, and snippets.

@bongster
Created December 12, 2014 13:14
Show Gist options
  • Save bongster/8e0304a854dfe68d2196 to your computer and use it in GitHub Desktop.
Save bongster/8e0304a854dfe68d2196 to your computer and use it in GitHub Desktop.
def solve(existsFolderCount: Int,
makeFolder: Int, folderListData: List[String]):Int = {
val result = folderListData.flatMap(folderData => {
println(folderData.split("/").mkString(", "))
val splitList:List[String] = folderData.split("/").toList
val splitSetList = (1 to splitList.size).map(n => splitList.take(n).mkString("/")).toList
splitSetList
}).toSet diff folderListData.take(existsFolderCount).toSet
result.size - 1
}
val folderListData1:List[String] = List("/home/gcj/finals","/home/gcj/quals")
assert(solve(0,2,folderListData1) == 4)
val folderListData2:List[String] = List("/chicken","/chicken/egg","/chicken")
assert(solve(2,1,folderListData2) == 0)
val folderListData:List[String] = List("/a", "/a/b", "/a/c", "/b/b")
assert(solve(1,3,folderListData) == 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment