Skip to content

Commit c1a29a8

Browse files
committed
1358
1 parent 5c58ae3 commit c1a29a8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# @param {String} s
2+
# @return {Integer}
3+
def number_of_substrings(s)
4+
count = 0
5+
last_indexes = [-1,-1,-1]
6+
(0...s.length).each { |i|
7+
last_indexes[s[i].ord - 97] = i
8+
count += last_indexes.min + 1
9+
}
10+
11+
count
12+
end

0 commit comments

Comments
 (0)