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

[高频题] 记录贴,互勉

🔗
 楼主| 微信用户_b99d1cc 2023-10-2 03:51:06 | 只看该作者
全局:
990. Satisfiability of Equality Equations
union-find solution:
Union the == character.   
Compare the != root

image.png (208.42 KB, 下载次数: 6)

image.png
回复

使用道具 举报

🔗
 楼主| 微信用户_b99d1cc 2023-10-2 05:08:42 | 只看该作者
全局:
721. Accounts Merge
1. map email to id
2. If the same email maps to a different id, union these two ids
3. put the email together with the root Id
4. sort the email and put them to an array, add the account name to the top.

image.png (238.16 KB, 下载次数: 7)

image.png
回复

使用道具 举报

🔗
 楼主| 微信用户_b99d1cc 2023-10-2 06:08:56 | 只看该作者
全局:
737. Sentence Similarity II
map a word to id, and union the id of each group
回复

使用道具 举报

🔗
 楼主| 微信用户_b99d1cc 2023-10-3 08:48:10 | 只看该作者
全局:
785. Is Graph Bipartite?
Graph coloring, For all node, the color as 1 or 2, if not visited should be 0 in the array.
If the current node and its neighbor have the same color, return false, else continue to color it as the opposite color

image.png (211.41 KB, 下载次数: 9)

image.png
回复

使用道具 举报

🔗
 楼主| 微信用户_b99d1cc 2023-10-4 07:55:29 来自APP | 只看该作者
全局:
886. Possible Bipartition
Same as 785,  but we need to build our graph first before do the coloring
And also the problem provided n is the number of people but not the number of dislike group

补充内容 (2023-10-04 08:07 +08:00):



补充内容 (2023-10-04 08:08 +08:00):

BFS approach

image.png (138.92 KB, 下载次数: 10)

image.png
回复

使用道具 举报

🔗
 楼主| 微信用户_b99d1cc 2023-10-4 08:50:09 | 只看该作者
全局:
1042. Flower Planting With No Adjacent

image.png (134.5 KB, 下载次数: 9)

image.png
回复

使用道具 举报

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

本版积分规则

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