public char firstAppear(String A, String B) {
char res = '\0';
if (A == null || B == null) {
return res;
}
for (int i = 0; i < A.length(); i++) {
for (int j = 0; j < B.length(); j++) {
if (A.charAt(i) == B.charAt(j)) {
res = A.charAt(i);
return res;
}
}
}
return res;
}
代码面试题:Find the first element in a given string A that also appears in another given string B
最新推荐文章于 2021-07-20 10:47:41 发布