1.Loop Invariants

free

⏱️ 2:45

2.Longest Consecutive Character

free

⏱️ 3:47

3.FizzBuzz ... Moore

free

⏱️ 4:24

4.Bracket Matching

free

⏱️ 2:55

5.Swap Two Variables In-Place

free

⏱️ 2:09

6.Array Sorting in JavaScript

⏱️ 3:45

7.Create a Linked List

free

⏱️ 4:40

8.Classic Linked List

⏱️ 2:05

9.Doubly Linked List

⏱️ 4:54

10.Revese a Linked List In-Place

⏱️ 3:45

11.Random Integers

⏱️ 3:30

12.Perfect Shuffle an Array

⏱️ 4:58

13.Derangement

⏱️ 3:48

14.Tree Data Structure Math Simplified

⏱️ 8:01

15.Queue Data Structure

⏱️ 7:23

16.Find the Repeated Item

⏱️ 3:32

17.Remove all Duplicates

⏱️ 3:25

18.Two Sum

⏱️ 3:37

19.Two Sum Sorted

⏱️ 3:36

20.Three Sum

⏱️ 7:23

Enjoy free content straight from your inbox 💌

00:00

If there is one programming concept that I could pick that will help you ace your coding interview, that will have to be loop in variance. In this lesson, we will demonstrate that with an example that is not particularly algorithmically complex, but will help solidify the concept in your mind so you can talk to it easily in more challenging scenarios. So let's take a look. Now, the programming challenge in question is to find the minimum number in an array of JavaScript numbers. So we've coded up this skeleton function where we take an input array of numbers and return the minimum number.

00:33

Now, the concept of lu in variance is that at any point looping through an input array, we want to maintain some fact about a particular variable. Now, maintaining this invariant or unchanging fact allows us to ensure that once we have gone through all the input elements, we can effectively answer a given question about the entire array. In our particular case, the question that we want to answer is that which number is the minimum? So if you haven't seen any numbers yet, we can effectively assume that the minimum number that we have essentially seen is infinity. And if just in case our input array contains no elements, this is a wise value to return as well.

01:08

Now the next step is to start looping through the input array, which we can do in JavaScript with a simple four of loop. Now, in each iteration of the loop, our objective is to maintain the invariant that the minimum variable points to the minimum value that we have seen so far. So after we see any value, we should check if it is less than the current minimum that we have stored. And if so, we need to update our minimum to this new value. This ensures that the invariant, that the minimum variable is pointing to the lowest value that we have seen so far continues to hold true as we see more and more items within the input array.

01:42

Therefore, when we have gone through all the items in the array, by definition, minimum is pointing to the least value within the input array and thus our correct answer. In terms of challenging programming questions, this was a pretty simple example, but my objective is always to explain the programming concepts in the easiest way possible. Now, just as an added bonus, I will also demonstrate how you would find math admin using JavaScript native functionality. So let's jump back in real World code. If you have to find the minimum of an array of numbers within JavaScript, you would actually use the built-in function

02:14

called math Do Min. That takes the various numbers as arguments. Now, in case you want to pass in an array of numbers, you can actually use the JavaScript spread operator to turn that array into positional arguments. And in our particular case, we have this array being passed in. So I'll replace this local array that I created for a demo and just use that one. An interesting side note is that the built-in JavaScript Math Min function also returns infinity if you give it an empty array, which is similar to the functionality that we wrote ourself.

1.Loop Invariants

free

⏱️ 2:45

2.Longest Consecutive Character

free

⏱️ 3:47

3.FizzBuzz ... Moore

free

⏱️ 4:24

4.Bracket Matching

free

⏱️ 2:55

5.Swap Two Variables In-Place

free

⏱️ 2:09

6.Array Sorting in JavaScript

⏱️ 3:45

7.Create a Linked List

free

⏱️ 4:40

8.Classic Linked List

⏱️ 2:05

9.Doubly Linked List

⏱️ 4:54

10.Revese a Linked List In-Place

⏱️ 3:45

11.Random Integers

⏱️ 3:30

12.Perfect Shuffle an Array

⏱️ 4:58

13.Derangement

⏱️ 3:48

14.Tree Data Structure Math Simplified

⏱️ 8:01

15.Queue Data Structure

⏱️ 7:23

16.Find the Repeated Item

⏱️ 3:32

17.Remove all Duplicates

⏱️ 3:25

18.Two Sum

⏱️ 3:37

19.Two Sum Sorted

⏱️ 3:36

20.Three Sum

⏱️ 7:23