2026.3.12 植树节
复健
学习灵神的解法
试试Python
Python确实比c++简单
加油小午
49
python
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
d=defaultdict(list)
for s in strs:
sorted_s=''.join(sorted(s))
d[sorted_s].append(s)
return list(d.values())
128
python
class Solution:
def longestConsecutive(self, nums: List[int]) -> int:
st=set(nums)
ans=0
for x in st:
if x-1 in st:continue
y=x+1
while y in st:y+=1
ans=max(ans,y-x)
return ans
我刚才反应过来昨天是植树节,感觉自己上小学的时候绝对不会忘记的哈哈