알고리즘
[알고리즘] Check If Two String Arrays are Equivalent
keel_im
2021. 1. 31. 23:56
반응형
포인트
1. string 을 합쳐서 비교를 할 수 있는가? 를 물어보는 문제 해결 방법은 간단하다.
🧶문서는 항상 수정 될 수 있습니다. 비판은 환영합니다.
cpp
class Solution {
public:
bool arrayStringsAreEqual(vector<string>& word1, vector<string>& word2) {
string a;
for (auto ele1: word1){
a+=ele1;
}
string b;
for(auto ele2: word2){
b+=ele2;
}
return a==b;
}
};
python
class Solution:
def arrayStringsAreEqual(self, word1: List[str], word2: List[str]) -> bool:
return (''.join(word1)==''.join(word2))
반응형