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.

Practical example of time complexity and big O

Practical example of time complexity and big O

From the course: Get Ready for Your Coding Interview

Practical example of time complexity and big O

- [Educator] Let's now take a look at another practical example of Time Complexity and Big O Notation and how you might be able to use them in a coding interview. In the previous chapter, we saw this problem. You're given a configuration of a chess board with some rooks. The problem was finding if any of the rooks can attack each other. We wanted to write a function, rooks are safe which returns true if none of the rooks are able to attack each other. Remember that rooks are able to move horizontally and vertically any number of spaces. This type of question is very common in a coding interview. Let's see how efficient our solution was. Our solution was this. We're going to count the number of rooks which are represented by ones for each row and each column. If there is a row or column that has two rooks or more then they can attack each other in that case, we'll return false from a function ,rooks are safe. Now…

Contents