Skip to content

Instantly share code, notes, and snippets.

@dellisd
Created May 28, 2019 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dellisd/877212891d6286a688b453e424301b32 to your computer and use it in GitHub Desktop.
Save dellisd/877212891d6286a688b453e424301b32 to your computer and use it in GitHub Desktop.
fun main() {
val k = readLine()!!.toInt()
for (i in 0 until k) {
val s = readLine()!!
val t = readLine()!!
var offset = 0
var answer = true
t.forEachIndexed { index, c ->
when (s.getOrNull(index + offset)) {
null -> answer = false
c -> {}
else -> if (c == '+') when (s.getOrNull(index + offset + 1)) {
'-' -> offset++
else -> answer = false
} else {
answer = false
}
}
}
if (s.length - offset != t.length) {
answer = false
}
println(if (answer) "YES" else "NO")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment