From the course: Get Ready for Your Coding Interview

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Why time complexity and big O notation?

Why time complexity and big O notation?

From the course: Get Ready for Your Coding Interview

Why time complexity and big O notation?

- [Instructor] In this chapter, we're going to talk about something called time complexity and big O notation, but why do we need them in the first place? Well, let's say in your coding interview, you're given a problem and you come up with two separate solutions or two separate functions. How do you know which one is a better solution? How do you know which function runs faster than the other one? You should be able to answer a question like this, because it's very common for the interviewer to ask something like, "How efficient is your solution?" And time complexity and big O notation are really good tools for answering these type of questions. Now, as an example, let's think about this question. How long does the following function take to complete? In the function, we first initialize X to zero, and for each item in the given list, we add that item to X. After that, we're going to return X. So this function simply finds a…

Contents