diff --git a/findCelebrity b/findCelebrity new file mode 100644 index 0000000..4c31683 --- /dev/null +++ b/findCelebrity @@ -0,0 +1,63 @@ +// Time Complexity :O(n*n) +// Space Complexity :O(n) +// Did this code successfully run on Leetcode :yes +// Any problem you faced while coding this :no +// Your code here along with comments explaining your approach:two pass algorithm with extra o(n) space + +/* The knows API is defined in the parent class Relation. + boolean knows(int a, int b); */ + +public class Solution extends Relation { + /** + * @param n a party with n people + * @return the celebrity's label or -1 + */ + public int findCelebrity(int n) { + // Write your code here + int[] people=new int[]; + for(int i=0;i