Skip to content

Commit

Permalink
leetcode count substrings starting and ending with given char
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatelmas committed Apr 30, 2024
1 parent 6040d65 commit 96dead6
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Solution:
def countSubstrings(self, s: str, c: str) -> int:
n = s.count(c)
return ((n + 1) * n) // 2

0 comments on commit 96dead6

Please sign in to comment.