본문 바로가기
python-algorithm

leetcode 3083. Existence of a Substring in a String and Its Reverse

by 무적김두칠 2024. 4. 24.

https://leetcode.com/problems/existence-of-a-substring-in-a-string-and-its-reverse/description/

 

1
2
3
4
5
6
7
8
class Solution:
    def isSubstringPresent(self, s: str-> bool:
        reverse_s = s[::-1]
        for i in range(1len(s)):
            if reverse_s[i-1:i+1in s:
                return True
        
        return False
cs
반응형

댓글