# 0602. Friend Requests II: Who Has the Most Friends

<https://leetcode.com/problems/friend-requests-ii-who-has-the-most-friends>

## Description

In social network like Facebook or Twitter, people send friend requests and accept others' requests as well.

Table `request_accepted`

```
+--------------+-------------+------------+
| requester\_id | accepter\_id | accept\_date|
|--------------|-------------|------------|
| 1            | 2           | 2016\_06-03 |
| 1            | 3           | 2016-06-08 |
| 2            | 3           | 2016-06-08 |
| 3            | 4           | 2016-06-09 |
+--------------+-------------+------------+
This table holds the data of friend acceptance, while **requester\_id** and **accepter\_id** both are the id of a person.
```

Write a query to find the the people who has most friends and the most friends number under the following rules:

* It is guaranteed there is only 1 people having the most friends.
* The friend request could only been accepted once, which mean there is no multiple records with the same **requester\_id** and **accepter\_id** value.

For the sample data above, the result is:

```
Result table:
+------+------+
| id   | num  |
|------|------|
| 3    | 3    |
+------+------+
The person with id '3' is a friend of people '1', '2' and '4', so he has 3 friends in total, which is the most number than any others.
```

**Follow-up:**\
In the real world, multiple people could have the same most number of friends, can you find all these people in this case?

## ac

```java
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jaywin.gitbook.io/leetcode/solutions/0602-friend-requests-ii-who-has-the-most-friends.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
