Skip to content

Commit 4f87d74

Browse files
committed
Sync LeetCode submission Runtime - 480 ms (33.63%), Memory - 61.4 MB (99.95%)
1 parent 4d53ec5 commit 4f87d74

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pandas as pd
2+
3+
def second_highest_salary(employee: pd.DataFrame) -> pd.DataFrame:
4+
employee = employee.drop_duplicates(['salary'])
5+
if len(employee['salary'].unique()) < 2:
6+
return pd.DataFrame({"SecondHighestSalary" : [None]})
7+
8+
employee = employee.sort_values('salary', ascending=False)
9+
employee.drop('id', axis=1, inplace=True)
10+
employee.rename({'salary': 'SecondHighestSalary'}, axis=1, inplace=True)
11+
return employee.head(2).tail(1)

0 commit comments

Comments
 (0)