Given two strings
In other words, return
Example 1:
Input: s1 = "ab", s2 = "eidbaooo" Output: true Explanation: s2 contains one permutation of s1 ("ba").
Example 2:
Input: s1 = "ab", s2 = "eidboaoo" Output: false
Constraints:
1 <= s1.length, s2.length <= 104 s1 ands2 consist of lowercase English letters.
Solution
要找 permutation 其實就是要把 s1 的每個字元都用到
所以在這題,只要改一下終止條件就可以
只要找到 subsstring 的長度和 s1 一樣,就可以回傳 true
如果沒找到,就回傳 false
kotlin
沒有留言:
張貼留言