Skip to content

Instantly share code, notes, and snippets.

@bloopepper
Last active November 2, 2020 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bloopepper/3e64465868d7e8651d59798e80c13ac3 to your computer and use it in GitHub Desktop.
Save bloopepper/3e64465868d7e8651d59798e80c13ac3 to your computer and use it in GitHub Desktop.
Check Array Formation Through Concatenation
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
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