🏆🏆🏆Beats 100% |✅✅✅ Easy Solution
\n\n# Intuition\n\uD83D\uDD0D The problem requires us to find the Nth highest salary from a list of employee salaries. If there is no Nth highest salary, we sho
![Screenshot 2024-06-05 220248.png](https://assets.leetcode.com/users/images/859529c6-a1e3-42f0-bca8-06dee2a5f6d0_1717605463.3639998.png)\n\n# Intuition\n\uD83D\uDD0D The problem requires us to find the Nth highest salary from a list of employee salaries. If there is no Nth highest salary, we should return null. This means we need to sort the unique salaries in descending order and then fetch the Nth value, considering edge cases where N is out of bounds.\n\n# Approach\n1) **Remove Duplicates**: \uD83E\uDDF9 Start by removing duplicate salary values from the dataframe to ensure each salary is considered only once.\n2) **Sort Salaries**: \uD83D\uDCCA Sort the unique salary values in descending order.\n3) **Check Bounds**: \u2753 Check if N is within the valid range (greater than 0 and less than or equal to the number of unique salaries). If not, return a DataFrame with null.\n4) **Fetch Nth Salary**: \uD83C\uDFC6 Fetch the Nth highest salary from the sorted list.\n5) **Return Result**: \u2705 Return the result in the required format.\n\n# Complexity\n- Time complexity:\nO(NlogN)\nN is the number of unique salaries\n- Space complexity:\nO(N)\n\n# Code\n```\nimport pandas as pd\n\ndef nth_highest_salary(df: pd.DataFrame, N: int) -> pd.DataFrame:\n    df = df[\'salary\'].drop_duplicates()\n    df = df.sort_values(ascending=False)\n    column = \'getNthHighestSalary(\'+str(N)+\')\'\n    if N > len(df) or N<=0:\n        return pd.DataFrame({column:[None]})\n    return pd.DataFrame({column:[df.iloc[N-1]]})\n```\n\n![Screenshot 2024-06-05 180939.png](https://assets.leetcode.com/users/images/6d823a97-f2d7-44a5-93f3-394d85c34135_1717605487.4027848.png)\n
['Pandas']