算法的重要性,我就不多说了吧,想去大厂,就必须要经过基础知识和业务逻辑面试+算法面试。所以,为了提高大家的算法能力,这个公众号后续每天带大家做一道算法题,题目就从LeetCode上面选 !
今天和大家聊的问题叫做 好友申请 I:总体通过率,我们先来看题面:
https://leetcode-cn.com/problems/friend-requests-i-overall-acceptance-rate/
解题
select
round(
ifnull(
(
select count(requester_id)
from
(
select requester_id , accepter_id
from RequestAccepted
group by requester_id , accepter_id
) as t1
)
/
(
select count(sender_id)
from
(
select sender_id, send_to_id
from FriendRequest
group by sender_id, send_to_id
) as t2
)
, 0
)
, 2)
as accept_rate
上期推文:
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有