class Solution {
public int solution(String myString, String pat) {
int answer = 0;
return answer;
}
}
class Solution {
public int solution(String myString, String pat) {
String str = "";
for (int i = 0; i < myString.length(); i++) {
if (myString.substring(i, i+1).equals("A")){
str += "B";
} else {
str += "A";
}
}
return str.contains(pat) ? 1 : 0;
}
}
String str = "";
substring(i, i+1) : 문자열 잘라내기
contains()
class Solution {
public int solution(String myString, String pat) {
int answer = 0;
String str = "";
String[] strArr = myString.split("");
for (int i = 0; i < strArr.length; i++) {
if (strArr[i].equals("A")) {
strArr[i] = "B";
} else if (strArr[i].equals("B")){
strArr[i] = "A";
}
str += strArr[i];
}
if (str.contains(pat)) {
answer = 1;
}
return answer;
}
}
split("")
equals()
contains()
class Solution {
public int solution(String myString, String pat) {
myString = myString.replace("A", "a").replace("B", "A").replace("a", "B");
return myString.contains(pat) ? 1 : 0;
}
}
replace() : replace() 를 이어서 사용할 수도 있다!