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

@problem@discussion
#Hash Table#String



1/**
2 * [3083] Existence of a Substring in a String and Its Reverse
3 *
4 * Given a string s, find any <span data-keyword="substring">substring</span> of length 2 which is also present in the reverse of s.
5 * Return true if such a substring exists, and false otherwise.
6 *  
7 * <strong class="example">Example 1:
8 * <div class="example-block" style="border-color: var(--border-tertiary); border-left-width: 2px; color: var(--text-secondary); font-size: .875rem; margin-bottom: 1rem; margin-top: 1rem; overflow: visible; padding-left: 1rem;">
9 * Input: <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">s = "leetcode"</span>
10 * Output: <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">true</span>
11 * Explanation: Substring "ee" is of length 2 which is also present in reverse(s) == "edocteel".
12 * </div>
13 * <strong class="example">Example 2:
14 * <div class="example-block" style="border-color: var(--border-tertiary); border-left-width: 2px; color: var(--text-secondary); font-size: .875rem; margin-bottom: 1rem; margin-top: 1rem; overflow: visible; padding-left: 1rem;">
15 * Input: <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">s = "abcba"</span>
16 * Output: <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">true</span>
17 * Explanation: All of the substrings of length 2 "ab", "bc", "cb", "ba" are also present in reverse(s) == "abcba".
18 * </div>
19 * <strong class="example">Example 3:
20 * <div class="example-block" style="border-color: var(--border-tertiary); border-left-width: 2px; color: var(--text-secondary); font-size: .875rem; margin-bottom: 1rem; margin-top: 1rem; overflow: visible; padding-left: 1rem;">
21 * Input: <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">s = "abcd"</span>
22 * Output: <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">false</span>
23 * Explanation: There is no substring of length 2 in s, which is also present in the reverse of s.
24 * </div>
25 *  
26 * Constraints:
27 * 
28 * 	1 <= s.length <= 100
29 * 	s consists only of lowercase English letters.
30 * 
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/existence-of-a-substring-in-a-string-and-its-reverse/
35// discuss: https://leetcode.com/problems/existence-of-a-substring-in-a-string-and-its-reverse/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40    pub fn is_substring_present(s: String) -> bool {
41        false
42    }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49    use super::*;
50
51    #[test]
52    fn test_3083() {
53    }
54}
55


Back
© 2025 bowen.ge All Rights Reserved.