
Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
History is littered with hundreds of conflicts over the future of a community, group, location or business that were "resolved" when one of the parties stepped ahead and destroyed what was there. With the original point of contention destroyed, the debates would fall to the wayside. Archive Team believes that by duplicated condemned data, the conversation and debate can continue, as well as the richness and insight gained by keeping the materials. Our projects have ranged in size from a single volunteer downloading the data to a small-but-critical site, to over 100 volunteers stepping forward to acquire terabytes of user-created data to save for future generations.
The main site for Archive Team is at archiveteam.org and contains up to the date information on various projects, manifestos, plans and walkthroughs.
This collection contains the output of many Archive Team projects, both ongoing and completed. Thanks to the generous providing of disk space by the Internet Archive, multi-terabyte datasets can be made available, as well as in use by the Wayback Machine, providing a path back to lost websites and work.
Our collection has grown to the point of having sub-collections for the type of data we acquire. If you are seeking to browse the contents of these collections, the Wayback Machine is the best first stop. Otherwise, you are free to dig into the stacks to see what you may find.
The Archive Team Panic Downloads are full pulldowns of currently extant websites, meant to serve as emergency backups for needed sites that are in danger of closing, or which will be missed dearly if suddenly lost due to hard drive crashes or server failures.
In a town, there are
N
people labelled from1
toN
. There is a rumor that one of these people is secretly the town judge.If the town judge exists, then:
You are given
trust
, an array of pairstrust[i] = [a, b]
representing that the person labelleda
trusts the person labelledb
.If the town judge exists and can be identified, return the label of the town judge. Otherwise, return
-1
.Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
1 <= N <= 1000
0 <= trust.length <= 10^4
trust[i].length == 2
trust[i]
are all differenttrust[i][0] != trust[i][1]
1 <= trust[i][0], trust[i][1] <= N
这道题是说是有N个人,里面有一个小镇法官,要求是法官不相信任何人,而其他所有人都信任法官,现在让我们找出这个法官,不存在的话返回 -1。跟之前那道
Find the Celebrity 非常相似,那道题是所有人都认识名人,但是名人不认识任何人。而这里是法官不相信人任何人,而所有人都相信法官,不同的是在于给的数据结构不同,名人那道是给了个 API 判断是否认识,而这里给了个信任数组,那么解法就稍有不同了。由于信任是有方向的,所以是一个有向图,因为法官不相信任何人,所以其没有出度,而所有人都信任他,则入度满值。最简单直接的方法就是统计每个结点的出度和入度,然后找出那个出度为0,入度为 N-1 的结点即可,参见代码如下:
解法一:
若没有想出有向图出度和入度的解法,也可以使用下面这种方法,思路是这样的,由于法官是不会相信任何人的,所以前一个位置的人肯定不是法官,则用一个 HashSet 来保存所有会相信别人的人,然后再用一个 HashMap 来建立某个人和信任该人的所有人的集合,那么只要找出不在 HashSet 中的人,且有 N-1 个人信任他,则该人一定是法官,其实本质上跟上面的解法还是一样的,参见代码如下:
解法二:
Github 同步地址:
#997
类似题目:
Find the Celebrity
参考资料:
https://leetcode.com/problems/find-the-town-judge/
https://leetcode.com/problems/find-the-town-judge/discuss/242938/JavaC%2B%2BPython-Directed-Graph
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: