Lists are a fundamental data structure for any program. When faced with a technical interview problem using lists, here are a few strategies to keep in mind:

  • Be comfortable with variables which represent indices in the list, or pointers.
    • Accessing the first and last values with indices.
    • Modding by the list length will ensure a valid index. (num % length_of_list).
    • Pointers can sometimes substitute for copying a list.
  • Ordered datasets unlock a lot of solutions.
    • Sorted data can be searched in O(logN) time using binary search.
    • Sorting can be done in O(N*logN) time.
  • Find the “naive” solution and push to optimize.
    • Interviewers want the optimal solution, but at least talk through the inefficient approach.


Run the code to see the difference in execution speed between optimal and naive solutions!

Sometimes the solution which optimizes for space will run slower.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?