Last active
November 2, 2020 14:23
-
-
Save bloopepper/3e64465868d7e8651d59798e80c13ac3 to your computer and use it in GitHub Desktop.
Check Array Formation Through Concatenation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
def canFormArray(self, arr, pieces): | |
""" | |
:type arr: List[int] | |
:type pieces: List[List[int]] | |
:rtype: bool | |
""" | |
mp = {x[0]: x for x in pieces} | |
res = [] | |
for num in arr: | |
res += mp.get(num, []) | |
return res == arr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
def countVowelStrings(self, n: int) -> int: | |
res = [1] * 5 | |
for _ in range(n-1): | |
for i in range(1, 5): | |
res[i] += res[i-1] | |
return sum(res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment