Flutter, Flutter App Development, Data Structures, Algorithms.
visited = <int>{}; final queue = Queue<int>(); queue.add(userId1); while (queue.isNotEmpty) { final userId = queue.removeFirst(); if (userId == userId2) { return true; } if (visited.contains(userId)) { continue; } visited.add(userId); for (final friend in users[userId]!.friends) {