Skip to content

Commit 5205117

Browse files
committed
solution added
1 parent e16698a commit 5205117

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutations is the substring of the second string.
3+
4+
5+
6+
Example 1:
7+
8+
Input: s1 = "ab" s2 = "eidbaooo"
9+
Output: True
10+
Explanation: s2 contains one permutation of s1 ("ba").
11+
Example 2:
12+
13+
Input:s1= "ab" s2 = "eidboaoo"
14+
Output: False
15+
16+
17+
Note:
18+
19+
The input strings only contain lower case letters.
20+
The length of both given strings is in range [1, 10,000].
21+
"""
22+
from itertools import permutations
23+
class Solution:
24+
def checkInclusion(self, s1: str, s2: str) -> bool:
25+
p = [''.join(p) for p in permutations(s1)]
26+
for string in p:
27+
if string in s2:
28+
return True
29+
return False

0 commit comments

Comments
 (0)