-
-
Save dellisd/877212891d6286a688b453e424301b32 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
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