Skip to content

Commit 8adc621

Browse files
add 597
1 parent 1dfc167 commit 8adc621

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ Your ideas/fixes/algorithms are more than welcome!
569569
|612|[Shortest Distance in a Plane](https://leetcode.com/problems/shortest-distance-in-a-plane/)|[Solution](../master/database/_612.sql) | || Medium|
570570
|610|[Triangle Judgement](https://leetcode.com/problems/triangle-judgement/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_610.java) | | | Easy |
571571
|607|[Sales Person](https://leetcode.com/problems/sales-person/)|[Solution](../master/database/_607.sql) | | | Easy |
572+
|597|[Friend Requests I: Overall Acceptance Rate](https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate/)|[Solution](../master/database/_597.sql) | | | Easy |
572573
|596|[Classes More Than 5 Students](https://leetcode.com/problems/classes-more-than-5-students/)|[Solution](../master/database/_596.sql) | || Easy |
573574
|595|[Big Countries](https://leetcode.com/problems/big-countries/)|[Solution](../master/database/_595.sql) | O(n) |O(1) | Easy |
574575
|586|[Customer Placing the Largest Number of Orders](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/)|[Solution](../master/database/_586.sql) | | | Easy|

database/_597.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--597. Friend Requests I: Overall Acceptance Rate
2+
3+
select
4+
round(
5+
ifnull(
6+
(select count(distinct requester_id,accepter_id) from request_accepted)
7+
/
8+
(select count(distinct sender_id, send_to_id) from friend_request)
9+
,0)
10+
,2)
11+
as accept_rate;
12+
13+
--The divisor (total number of requests) could be '0'
14+
--if the table friend_request is empty.
15+
--So, we have to utilize ifnull to deal with this special case.

0 commit comments

Comments
 (0)