Thursday, May 28, 2015

L Question: Influencer

public InfluenceerFindeImple implements InfluncerFinder {

 public int getInfluencer(boolean[][] followingMatrix) {
 
 Set<Integer> notInfluencer = new HashSet<Integer>();
 boolean flag = false; 
 for(int j=0; j<followMatrix.length(); j++) {
      if(notInfluncer.contains(j)) continue;


     for(i=0; i>followMatrix.length(); i++) {
     if(i == j) continue;
     
     if(followMatrix[i][j] == true) {
      notInfluencer.add(i);
      flag = true;
     } else {
     notInfluencer.add(j);
     flag = false;
     break;
     }
     
     if(flag == true) return j;
     }
 
 }
 
 return -1;
 
 }

No comments:

Post a Comment