五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

LeetCode 2720. Popularity Percentage

2023-07-04 15:31 作者:您是打尖兒還是住店呢  | 我要投稿

Description

Table:?Friends

+-------------+------+?

| Column Name | Type |?

+-------------+------+?

| user1 ? ? ? | int ?| | user2 ? ? ? | int ?|?

+-------------+------+?

(user1, user2) is the primary key of this table. Each row contains information about friendship where user1 and user2 are friends.

Write an SQL query to find the popularity percentage for each user on Meta/Facebook. The popularity percentage is defined as the total number of friends the user has divided by the total number of users on the platform, then converted into a percentage by multiplying by 100,?rounded to 2 decimal places.

Return?the result table ordered by?user1?in?ascending?order.

The query result format is in the following example.

?

Example 1:

Input:??

Friends table:?

+-------+-------+?

| user1 | user2 |

+-------+-------+

| 2 ? ? | 1 ? ? |?

?| 1 ? ? | 3 ? ? |?

| 4 ? ? | 1 ? ? |?

| 1 ? ? | 5 ? ? |?

| 1 ? ? | 6 ? ? |

?| 2 ? ? | 6 ? ? |

?| 7 ? ? | 2 ? ? |?

?| 8 ? ? | 3? ? ?|?

?| 3 ? ? | 9 ? ? |?

? +-------+-------+

Output:?

+-------+-----------------------+

?| user1 | percentage_popularity |

?+-------+-----------------------+

| 1 ? ? | 55.56 ? ?? ? ? ? ? ? ?|?

| 2 ? ? | 33.33 ? ?? ? ? ? ? ? ?|?

| 3 ? ? | 33.33 ? ? ? ? ? ? ? ? |

?| 4 ? ? | 11.11 ? ? ? ? ? ? ? ? |

?| 5 ? ? | 11.11 ? ? ? ? ? ? ? ? |

?| 6 ? ? | 22.22 ? ? ? ? ? ? ? ? |?

| 7 ? ? | 11.11 ? ? ? ? ? ? ? ? |?

| 8 ? ? | 11.11 ? ? ? ? ? ? ? ? |

| 9 ? ? | 11.11 ? ? ? ? ? ? ? ? |

?+-------+-----------------------+

Explanation:?

?There are total 9 users on the platform.?

- User "1" has friendships with 2, 3, 4, 5 and 6. Therefore, the percentage popularity for user 1 would be calculated as (5/9) * 100 = 55.56.?

- User "2" has friendships with 1, 6 and 7. Therefore, the percentage popularity for user 2 would be calculated as (3/9) * 100 = 33.33.?

- User "3" has friendships with 1, 8 and 9. Therefore, the percentage popularity for user 3 would be calculated as (3/9) * 100 = 33.33.?

- User "4" has friendships with 1. Therefore, the percentage popularity for user 4 would be calculated as (1/9) * 100 = 11.11.?

- User "5" has friendships with 1. Therefore, the percentage popularity for user 5 would be calculated as (1/9) * 100 = 11.11.?

- User "6" has friendships with 1 and 2. Therefore, the percentage popularity for user 6 would be calculated as (2/9) * 100 = 22.22.?

- User "7" has friendships with 2. Therefore, the percentage popularity for user 7 would be calculated as (1/9) * 100 = 11.11.

- User "8" has friendships with 3. Therefore, the percentage popularity for user 8 would be calculated as (1/9) * 100 = 11.11.?

- User "9" has friendships with 3. Therefore, the percentage popularity for user 9 would be calculated as (1/9) * 100 = 11.11. user1 is sorted in ascending order.

下面是代碼:



LeetCode 2720. Popularity Percentage的評論 (共 條)

分享到微博請遵守國家法律
泗水县| 康马县| 德格县| 柘荣县| 大新县| 仪陇县| 泸溪县| 罗田县| 江西省| 霍城县| 建湖县| 瓦房店市| 含山县| 齐河县| 诸暨市| 阳曲县| 镇宁| 彭州市| 湖州市| 霍州市| 乌兰县| 湖南省| 承德市| 会泽县| 海盐县| 宁乡县| 新巴尔虎右旗| 平顶山市| 工布江达县| 乌恰县| 威信县| 白玉县| 阿鲁科尔沁旗| 丰镇市| 平和县| 封开县| 邢台县| 湘潭市| 瑞金市| 洛扎县| 临洮县|