SHARE
TWEET

Untitled

a guest Jun 20th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   // Функция принимает маccив людей
  2.   // и возвращает
  3.   // либо человека которого знают вcе и он не знает никого,
  4.   // либо null, еcли такого челоевка нет
  5.   People searchStar(List<People> peoples) {
  6.     int x = 0, y = 1;
  7.    
  8.     while (y < peoples.size()) {
  9.       if (isFirstKnowSecond(peoples.get(x), peoples.get(y))) x = y;
  10.       y++;
  11.     }
  12.    
  13.     for (int i = 0; i < peoples.size(); i++) {
  14.       if (i == x) continue;
  15.       if (i <= x-1 && isFirstKnowSecond(peoples.get(x), peoples.get(i))) return null;
  16.       if (!isFirstKnowSecond(peoples.get(i), peoples.get(x))) return null;
  17.     }
  18.    
  19.     return peoples.get(x);
  20.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top