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
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Why time complexity and big O notation?1m 52s
-
(Locked)
Overview of time complexity4m 9s
-
(Locked)
Overview of big O notation5m 53s
-
(Locked)
Evaluating time complexity using big O3m 16s
-
(Locked)
Practical example of time complexity and big O2m 39s
-
(Locked)
Sample interview question #4: Big O1m 17s
-
(Locked)
Visual solution to sample question #43m 5s
-
(Locked)
Code solution to sample question #43m 51s
-
(Locked)
-
-