LeetCode #3083

Existence of a Substring in a String and Its Reverse

1개의 풀이 · C++

문제 원문 보기 ↗

SOLUTION INFO

C++ · main.cpp

main.cpp
class Solution {
public:
    bool isSubstringPresent(string s) {
        string t = s; reverse(t.begin(), t.end());
        int n = (int)s.size();
        for(int i = 0; i + 1 < n; ++i) {
            auto it = s.substr(i, 2);
            for(int j = 0; j + 1 < n; ++j) {
                if(t.substr(j, 2) == it)return true;
            }
        }
        return false;
    }
};

SOLUTION DESCRIPTION

풀이 설명

등록된 풀이 설명이 없습니다.