Concise MySQL solution with reference


  • 2
    Z
    # Refer to: https://stackoverflow.com/questions/17250243/how-to-return-null-when-result-is-empty
    select(
      select num
      from number
      group by num
      having count(*) = 1
      order by num desc limit 1
    ) as num;
    

  • 0

    Same idea

    select max(a.num) as num
    from (select num from number group by num having count(*)=1) as a

Log in to reply
 

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