kt: add «392. Is Subsequence»

URL:	https://leetcode.com/problems/is-subsequence/
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2025-02-08 23:39:01 +01:00
parent 589ae3bcea
commit 17451369aa
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

20
kt/is-subsequence.kt Normal file
View file

@ -0,0 +1,20 @@
class Solution {
fun isSubsequence(
s: String,
t: String,
): Boolean {
var i = 0
for (j in t.indices) {
if (i < s.length && t[j] == s[i]) {
i++
}
if (i >= s.length) {
break
}
}
return i == s.length
}
}