Skip to content

Commit 291791b

Browse files
authored
Update Find Maximum Number of String Pairs.py
1 parent 553b9ef commit 291791b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Find Maximum Number of String Pairs.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,13 @@ def maximumNumberOfStringPairs(self, words: List[str]) -> int:
3838
return sum(map((lambda x: x*(x-1)), d.values()))//2
3939

4040
---------------------------------------------------------------------------------------
41+
42+
class Solution:
43+
def maximumNumberOfStringPairs(self, words: List[str]) -> int:
44+
count=0
45+
s=set()
46+
for ele in words:
47+
if ele[::-1] in s:
48+
count+=1
49+
s.add(ele)
50+
return count

0 commit comments

Comments
 (0)