Skip to content

Instantly share code, notes, and snippets.

@kazua
Last active December 15, 2015 04:50
Show Gist options
  • Save kazua/5204399 to your computer and use it in GitHub Desktop.
Save kazua/5204399 to your computer and use it in GitHub Desktop.
世界で闘うプログラマ本の1-1
//write kazua
import scala.collection.mutable._
object worldproblem1_1 {
def UniqueCheck(chkstr : String) : Boolean = {
if (chkstr.length == 0 && chkstr.length > 256) return false
val chrmp = Map[Char, Boolean]()
for (i <- 0 to chkstr.length - 1) {
val ch = chkstr.charAt(i)
if (chrmp.contains(ch)) return chrmp(ch)
else chrmp(ch) = false
}
true
}
def main(args : Array[String]) {
println(UniqueCheck("abcgdjwp"))
println(UniqueCheck("abcadjwp"))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment