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.
Code solution to sample question #4
From the course: Get Ready for Your Coding Interview
Code solution to sample question #4
- Let's see what my Lea time solution might look like and could. The problem was counting the number of negative numbers in a two-dimensional array, in which each column and each row are already sorted. Let's implement our function right here. At the beginning of this function we'll initialize a new variable called, "Count to zero." And we're going to use this variable to keep track of the number of negative numbers we've seen so far. And then we're going to use two variables: "row_i" for row index and "col_i" for column index to keep track of which number we're examining currently. And since the first number that we're going to examine is the number at the top right corner, so we're going to initialize row_i to zero and col_i to length of given array. Square brackets zero, minus one, since we'll start at the last column of this array. After that, we're going to run a while loop with while col_i is larger…
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)
-
-