Created
December 12, 2014 13:14
-
-
Save bongster/8e0304a854dfe68d2196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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