Skip to content

Instantly share code, notes, and snippets.

@e-tverdokhleb
Created September 30, 2021 14:38
Show Gist options
  • Save e-tverdokhleb/e08a14cdef958793f375a953cbc0bfca to your computer and use it in GitHub Desktop.
Save e-tverdokhleb/e08a14cdef958793f375a953cbc0bfca to your computer and use it in GitHub Desktop.
TASK_EQUALS
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
const val t = "TEST"
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
checkString()
}
private fun checkString(s: String = "bsTmEvdbSSSSSSgvTfdsf") {
println("s: $s")
var j = 0
for (i in 0..s.length - 1) {
println("s[$i]=${s[i]}")
if (s[i] == t[j]) {
println("EQUALS s[$i]:${s[i]} == t[$j]:${t[j]}")
if (j < t.length - 1) {
println("t[$j]=${t[j]}")
j++
continue
} else if (j >= t.length - 1) {
println("SUCCESS")
break
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment