3084. Count Substrings Starting and Ending with Given Character
You are given a string s and a character c. Return the total number of substrings of s that start and end with c. Example 1: Input: s = "abada", c = "a" Output: 6 Explanation: Substrings starting and ending with "a" are: "abada", "abada", "abada", "abada", "abada", "abada". Example 2: Input: s = "zzz", c = "z" Output: 6 Explanation: There are a total of 6 substrings in s and all start an
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start