1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-14 01:49:41 +01:00
LeetCode/java/find-words-that-can-be-formed-by-characters.java
Matej Focko 2351dfd0ee
chore: unwrap one layer
Signed-off-by: Matej Focko <mfocko@redhat.com>
2023-12-12 14:36:00 +01:00

27 lines
646 B
Java

class Solution {
public boolean arrayStringsAreEqual(String[] word1, String[] word2) {
int i = 0, ii = 0;
int j = 0, jj = 0;
while (i < word1.length && j < word2.length) {
if (word1[i].charAt(ii) != word2[j].charAt(jj)) {
return false;
}
++ii;
++jj;
if (ii >= word1[i].length()) {
++i;
ii = 0;
}
if (jj >= word2[j].length()) {
++j;
jj = 0;
}
}
return i == word1.length && j == word2.length && ii == 0 && jj == 0;
}
}