Last updated on January 21st, 2025 at 10:04 pm
Here, we see the Biggest Single Number LeetCode Solution. This Leetcode problem is solved using MySQL and Pandas.
List of all LeetCode Solution
Level of Question
Easy
Biggest Single Number LeetCode Solution
Table of Contents
1. Problem Statement
Column Name | Type |
num | int |
MyNumbers
This table may contain duplicates (In other words, there is no primary key for this table in SQL). Each row of this table contains an integer.
A single number is a number that appeared only once in the MyNumbers
table.
Find the largest single number. If there is no single number, report null
.
The result format is in the following example.
Example 1:
Input:
num |
8 |
8 |
3 |
3 |
1 |
4 |
5 |
6 |
Output:
num |
6 |
Explanation: The single numbers are 1, 4, 5, and 6. Since 6 is the largest single number, we return it.
Example 2:
Input:
num |
8 |
8 |
7 |
7 |
3 |
3 |
3 |
num |
null |
Explanation: There are no single numbers in the input table so we return null.
2. Code Implementation in Different Languages
2.1 Biggest Single Number MySQL
select max(num) as num from ( select num from my_numbers group by num having count(num) = 1 ) as n;