Skip to content

Practice Existence of a Substring in a String and Its Reverse

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3083
LeetCode Problem

Existence of a Substring in a String and Its Reverse

Problem Statement

Given a string s, find any substring of length 2 which is also present in the reverse of s. Return true if such a substring exists, and false otherwise.

Source: Existence of a Substring in a String and Its Reverse on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "leetcode"
Output
true

# Example 2

Input
s = "abcba"
Output
true

# Example 3

Input
s = "abcd"
Output
false

Constraints

1 <= s.length <= 100
s consists only of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Existence of a Substring in a String and Its Reverse.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.