Skip to content

Commit 892c158

Browse files
authored
Merge pull request #95 from nexi9/newBranch
Create arrayStringsAreEqual.java
2 parents 4ec7eab + 79c4681 commit 892c158

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Coding/arrayStringsAreEqual.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class Solution {
2+
public boolean arrayStringsAreEqual(String[] w1, String[] w2) {
3+
int wInd1 = 0;
4+
int wInd2 = 0;
5+
int ind1 = 0;
6+
int ind2 = 0;
7+
while (wInd1 < w1.length && wInd2 < w2.length) {
8+
if (ind1 == w1[wInd1].length() || ind2 == w2[wInd2].length()) {
9+
if (ind1 == w1[wInd1].length()) {
10+
wInd1++;
11+
ind1 = 0;
12+
}
13+
if (ind2 == w2[wInd2].length()) {
14+
wInd2++;
15+
ind2 = 0;
16+
}
17+
} else {
18+
if (w1[wInd1].charAt(ind1) != w2[wInd2].charAt(ind2)) {
19+
return false;
20+
}
21+
ind1++;
22+
ind2++;
23+
}
24+
}
25+
return wInd1 == w1.length && wInd2 == w2.length;
26+
}
27+
}

0 commit comments

Comments
 (0)