This is a popular algorithm problem that can be solved with the Greedy Algorithm approach. This is an excellent example to learn how to think in the *Greedy Way.*

In layman’s terms, the greedy way takes the advantage of a locally optimal solution to scale out to a globally optimal solution.

Now, let’s take a look at the problem statement.

We are given a list (sticking with the Python tongue cause I cannot stop loving it!) of **positive** integers and we have to find the *maximum **even** sum *for **K **elements from the list. …

This is a popular algorithmic problem that involves finding the longest substring containing the same letters after replacing a certain number of letters. The sliding window pattern is employed to solve the problem.

Try the problem on educative!

Although the solution is pretty descriptive on educative, the lack of visualization, a more step-by-step approach to the algorithm and a walkthrough with the sample I/O is what prompted me to write this post.

Input:

`String="aabccbb", k=2`

Output:

`5`

Explanation:

`Replace the two 'c' with 'b' to have a longest repeating substring "bbbbb".`

Similarly,

`Input: String="abbcb", k=1`

Output: 4

Explanation: Replace the 'c' with…

This is a popular algorithm problem that involves a **list** of integers which indicate meeting time slots in a calendar. The target is to return a **merged** list by merging the overlapping time slots.

Found it on InterviewCake. Although their descriptive solution was super helpful, the lack of visuals is what prompted me to write up this post. Since I Love Python, I am sticking to jargon specific to it. All of it should be pretty transferable to any other programming language!

Considering the time slots start from 9:00am, let’s imagine the input contains integers which are 30-minute blocks past…

The problem is borrowed from InterviewCake. Although they did a great job explaining the solution in detail, there aren’t that many visuals.

This post is my attempt to visualize the solution:

Input: ‘cat’

output: {‘cat’, ‘atc’, ‘act’, ‘tca’, ‘tac’, ‘cta’}

**Let’s start small. With 2 chars only.**

Suppose we had `ca`

as input.

Their permutations will be:

`ca, ac`

Notice that if we separated out the last char `a`

and only had `c`

then we are basically attaching the last char (a) into 2 different positions:

**Next, let’s add another char.**

Suppose we had `cat`

as input:

Similar as above…

This problem is straight outta InterviewCake. Attempted to solve it but got stuck and eventually looked into the solution. Sadly, the solution wasn’t visual enough for me, although it was pretty descriptive. As a visual learner, I couldn’t stop but write this post with some visuals that are just some neat versions of the ones I jotted down on my notebook!

Here goes some more description on the problem:

**Write a function get_products_of_all_ints_except_at_index() that takes a list of integers and returns a list of the products.**

For example, given:

`[1, 7, 3, 4]`

Your function would return:

`[84, 12, 28…`

The problem statement is to find the next greatest element in a linked List. So for the *ith* node we have to find the *jth *node, such that node value of j is greater than *ith.*

The catch here is that we have to find the most recent one. Let’s take an example:

**[2,1,5]**

output => [5,5,0]

notice that for i=0, the greatest element after 2 is 5

for i = 1, next greatest = 5

for i = 2, does not have any next greatest, hence the zero 0

Another example,

`[1,7,5,1,9,2,5,1]`

output => [7,9,9,9,0,5,0,0]

running…

**Try it yourself on ****UVa****. It’s Fun!**

This problem has also been part of the programming challenges on the Algorithm Design Manual’s chapter 2.

The premise of the problem can be chalked out like this way:

- A guy goes along corridor
*N*times which have*N*bulbs - Every time he goes along the corridor he toggles the switch of
*certain*bulbs based on certain**condition** - We have to determine the
**state**of the last bulb i.e.**Nth**bulb.

The conditions are as follows:

- The bulbs have serial numbers starting from 1 to N i.e. …

Well, the title speaks for itself!

**Try it yourself on ****HackerRank**

Apparently this is quite a common interview question (asked at Google Phone Screen). Sadly, I couldn’t find some good visualizations to understand the underlying logic behind the solving this problem. So, I couldn’t help but write one for myself.

In this post we explore the minimum swaps required to sort, and array/list of **consecutive** integers, note that the case of non-consecutive integers will be slightly different.

We are given a list (since I use Python, sticking to “list” 😐) a *N *integers such that

- 1 ≤ N ≤ 10⁵
- …

Recently I came across the issue of using the **auth **module in Nuxt.js and invoking a $**router.push **in subsequent line of code in the same method. The conundrum began when the lines after the **auth.loginWith **method did not execute as intended since the page was redirected to the redirect URI.

It has been only a week in the Vue.js land, so I suppose this issue is something faced by many newbies.

So, here goes where it all started:

I have a ** authenticate() **function, whose body looks like:

Now, notice that once the **line: 2** gets invoked, the execution is…