shouldn't we consider the duplicated requests?


  • 0
    Z

    just borrow the idea from Friend Request I, there might be a case when two same requests are sent and accepted (as explained in Q I). So I tried to take this into consideration instead of simply count the frequency that a single id occurs (either as a requester_id or accepter_id)

    but my code can't pass the test and is announced wrong. I'm confused.Can someone help to point out my mistake? Thanks!

    select id, sum(num)as num from
    (select requester_id as id, count(distinct requester_id,accepter_id)as num from request_accepted group by requester_id
    union all
    select accepter_id as id, count(distinct requester_id,accepter_id)as num from request_accepted group by accepter_id)as stat1
    group by id
    order by num DESC limit 1;
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.