楼主: studygirl
跳转到指定楼层
上一主题 下一主题
收起左侧

刷题打卡,现在刷了329题。

🔗
 楼主| studygirl 2022-4-21 13:14:58 | 只看该作者
全局:
705. Design HashSet
it is a easy one, so just simple use the set
回复

使用道具 举报

🔗
 楼主| studygirl 2022-4-22 13:03:57 | 只看该作者
全局:
706. Design HashMap

it different with the desin hashset

input value is key or key value
回复

使用道具 举报

🔗
 楼主| studygirl 2022-4-24 13:31:11 | 只看该作者
全局:
1396. Design Underground System
回复

使用道具 举报

🔗
 楼主| studygirl 2022-4-26 02:15:40 | 只看该作者
全局:
284. Peeking Iterator
回复

使用道具 举报

🔗
 楼主| studygirl 2022-4-27 14:56:51 | 只看该作者
全局:
1202. Smallest String With Swaps
回复

使用道具 举报

🔗
 楼主| studygirl 2022-4-27 15:16:07 | 只看该作者
全局:
class Solution:
    def smallestStringWithSwaps(self, s: str, pairs: List[List[int]]) -> str:
         
        class UF:
            def __init__(self, n):
                self.p = list(range(n))
            def union(self, x, y):
                self.p[self.find(x)] = self.find(y)
            def find(self, x):
                if x != self.p[x]:
                    self.p[x] = self.find(self.p[x])
                return self.p[x]
            
        uf, res, m = UF(len(s)), [], defaultdict(list)
        for x,y in pairs:
            uf.union(x,y)
        
        for i in range(len(s)):
            m[uf.find(i)].append(s[i])
        print(m)
        for comp_id in m.keys():
            m[comp_id].sort(reverse=True)
        print(m)
        for i in range(len(s)):
            res.append(m[uf.find(i)].pop())
        return ''.join(res)
回复

使用道具 举报

🔗
 楼主| studygirl 2022-4-29 15:14:36 | 只看该作者
全局:
785. Is Graph Bipartite?
回复

使用道具 举报

🔗
 楼主| studygirl 2022-4-29 15:15:14 | 只看该作者
全局:
1631. Path With Minimum Effort
difficult
回复

使用道具 举报

🔗
 楼主| studygirl 2022-5-1 01:08:24 | 只看该作者
全局:
399. Evaluate Division
回复

使用道具 举报

🔗
 楼主| studygirl 2022-5-2 11:47:26 | 只看该作者
全局:
844. Backspace String Compare
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表