# 383
class Solution:
def canConstruct(self, ransomNote: str, magazine: str) -> bool:
R = Counter(ransomNote)
M = Counter(magazine)
for i in R:
if R[i] > M[i]:
return False
return True
# 386
class Solution:
def lexicalOrder(self, n: int) -> List[int]:
res = []
for i in range(1 , n + 1):
res.append(i)
return sorted(res , key = str)
# 387
class Solution:
def firstUniqChar(self, s: str) -> int:
S = Counter(s)
for i in S:
if S[i] == 1:
tmp = i
return s.find(i)
return -1
# 389
class Solution:
def findTheDifference(self, s: str, t: str) -> str:
count_s = collections.Counter(s)
count_t = collections.Counter(t)
for c in count_t:
if count_t[c]!=count_s[c]:
return c
# 390
class Solution:
def lastRemaining(self, n: int) -> int:
return 1 if n == 1 else 2 * (n // 2 + 1 - self.lastRemaining(n // 2))