Web appOpen in Telegram

PostSubstrings that begin and end with the same letter

18 December 2024
<
< Ace Coding /> 🚀
Substrings that begin and end with the same letter You are given a 0-indexed string s consisting of only lowercase English letters. Return the number of substrings in s that begin and end with the same character. A substring is a contiguous non-empty sequence of characters within a string. Example 1: Input: s = "abcba" Output: 7 Explanation: The substrings of length 1 that start and end with the same letter are: "a", "b", "c", "b", and "a". The substring of length 3 that starts and ends with the same letter is: "bcb". The substring of length 5 that starts and ends with the same letter is: "abcba" . Example 2: Input: s = "abacad" Output: 9   112131 Explanation: The substrings of length 1 that start and end with the same letter are: "a", "b", "a", "c", "a", and "d" = 6. The substrings of length 3 that start and end with the same letter are: "aba" and "aca" = 2. The substring of length 5 that starts and ends with the same letter is: "abaca" = 1. Example 3: Input: s = "a" Output: 1 Explanation: The substring of length 1 that starts and ends with the same letter is: "a". Constraints: 1 <= s.length <= 105 s consists only of lowercase English letters.
5 · 244 ·

Nearby in the feed

<< Ace Coding /> 🚀✅ Sliding window, Two pointers, and Hash Table problem 🟡 567. Permutation in String https://leetcode.com/problems/permutation-in-string/submissions/1482104785/ << Ace Coding /> 🚀✅ Dynamic Sliding window and hashmap / hashset problem. This problem has a pattern that repeats a lot : worth revising 🟡 3. Longest Substring Without Repeating
this message
<< Ace Coding /> 🚀question from today interview question<< Ace Coding /> 🚀Question: Maximum Sum Score of an Array You are given a 0-indexed integer array nums of length n. The sum score of nums at an index i (where 0 <= i < n) is defi
<< Ace Coding /> 🚀< Ace Coding /> 🚀@AceCoding · channel · Tech
334subscribers345posts in the index
Venue feed Open in Telegram

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · What we do not do · Remove a page · Catalog · Search · How we count