Skip to content

Commit 7dd2e6a

Browse files
fix: 增加对N的判断,避免N为负数或0导致不通过
1 parent 1c85b98 commit 7dd2e6a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

solution/0100-0199/0177.Nth Highest Salary/Solution.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33

44
def nth_highest_salary(employee: pd.DataFrame, N: int) -> pd.DataFrame:
5+
if N < 1:
6+
return pd.DataFrame({"getNthHighestSalary(" + str(N) + ")": [None]})
57
unique_salaries = employee.salary.unique()
68
if len(unique_salaries) < N:
79
return pd.DataFrame([np.NaN], columns=[f"getNthHighestSalary({N})"])

0 commit comments

Comments
 (0)