Find the Celebrity
来源:互联网 发布:ccer金融数据库 编辑:程序博客网 时间:2024/05/22 12:37
/* The knows API is defined in the parent class Relation. boolean knows(int a, int b); */public class Solution extends Relation { public int findCelebrity(int n) { int can = 0; for (int i = 1; i < n; i++) { if (!knows(i, can)) { can = i; } } for (int i = 0; i < n; i++) { if (i != can && (knows(can, i) || !knows(i, can))) { return -1; } } return can; }}
0 0
- Leetcode: Find the Celebrity
- *LeetCode-Find the Celebrity
- [LeetCode277]Find the Celebrity
- Find the Celebrity
- Leetcode Find the Celebrity
- Find the Celebrity
- Find the Celebrity
- Find the Celebrity
- leetcode Find the Celebrity
- Find the Celebrity
- Find the Celebrity
- 277. Find the Celebrity
- 277. Find the Celebrity
- 277. Find the Celebrity
- leetcode 277: Find the Celebrity
- Leetcoed 277Find the Celebrity
- LeetCode 277. Find the Celebrity
- Leetcode 277. Find the Celebrity
- The Skyline Problem
- Product of Array Except Self
- Minimum Size Subarray Sum
- 100多个优秀的互联网编程学习平台整理。
- UIButton无法响应点击事件
- Find the Celebrity
- Meeting Rooms II
- Maximum Size Subarray Sum Equals k
- Simplify Path
- comment/uncomment lines in Vim
- 查看CPU支持的指令集
- 《c primer plus》第一个程序first.c的编辑,编译与输出
- bitset
- Leetcode 383. Ransom Note