Dark code-style academy (Part I)

Dark code-style academy (Part I)

Do you want to raise your salary? Do you want always to be in demand? Do you want to have your job as long as you want? It is absolutely real! You just need to change the way you write your code. Basically, you need to increase your job security. You have to write code which will be almost impossible to maintain for everyone except you. And in these series of articles, I will tell you how to achieve it. Welcome under the cut.

Continue reading “Dark code-style academy (Part I)”

Visual Studio vs Rider

Visual Studio vs Rider

As long as you reading this post, you are a kind of .NET developer. So, there is a huge possibility that you don’t even know what Rider is. Or, moreover, you are already “negatively tuned” about this IDE because you’ve been working with VS for a long time. Ok, then, if you stuck there I will help you to get out of this hole.

I am not going to discuss their features comparing each other. I was working with Visual Studio starting from the 2003 version, so I think I understand how much you love it. I just want to give you guys some thoughts and motivation to consider Rider as your new IDE. Welcome under the cut!

Continue reading “Visual Studio vs Rider”

Longest Palindromic Substring

Today, we will discover one of the basics algorithms to find the longest palindromic substring.

Problem:
Given a string S, find the longest palindromic substring in S.

Difficulty: Easy

Practice: Leetcode

Examples:

1. S = "abad", Result = "aba"
2. S = "codeedoc", Result = "codeedoc"

Solution:
To come up with a solution we need to understand what the palindrome is. Basically, this is just a word which reads the same backward as forward (for more details see).

The main idea is to find all palindromes in S with even and odd lengths and keep track which one is the longest. To find odd length palindromes we fix center for every letter in S and expand it in both directions.

Longest Palindromic Substring

To find even length palindrome we fix center between two nearby letters in S and also expand it in both directions.

Longest Palindromic Substring

While expanding, if two opposite letters are equal then we add them to our potential palindrome.

Time complexity: O(N^2)
Space complexity: O(1)

That’s all for today. You can find the source code here, but I suggest you implement it by yourself.

Thank you for reading my blog and see you in a leaderboard :)

Longest Common Substring

In this post, we will discover the basic algorithm to find the longest common substring of two strings.

Problem: Given two strings X and Y, find the longest common substring.

Difficulty: Easy

Examples:

1. X = "timetocode", Y = "timerightnow", Result = "time"
2. X = "abcabdef", Y = "abdf", Result = "abd"

Solution: Dynamic Programming
To solve this problem, we need to find all occurrences of all X letters in Y string. To keep intermediate results we can use a two-dimensional array of length X and Y accordingly.

Longest Common Substring

Even now we can see the result. But to make it more clear, let’s add some rules how to fill this table:
1. If X letter is not equal to Y letter then Table[i][j] = 0.
2. If X letter is equal to Y letter then this is already common substring of length 1. If the previous letter was also substring then the length of a new substring is Table[i][j] = Table[i - 1][j - 1] + 1 (prev length + current length).

Longest Common Substring

Obviously, the length of the longest common substring is the maximum value in this table. And the actual substring can be reproduced by previous cells from the cell with maximum value to the cell with a value of one.

Time complexity: O(N^2)
Space complexity: O(|X| * |Y|)

The source code for this problem you may find here. Thank you for reading my blog and have a nice coding!

Level up VIM skills

Level up VIM skills

Over two years I’ve been using VIM as the main development tool. From plugin for Visual Studio to complete IDE for JS and Go projects. In this post, I’m going to level up your VIM experience by sharing my best practices, most used hotkeys and awesome plugins. If you are interested in then welcome into my VIM-world. But if don’t know what the hell it is or you don’t have enough confidence when using VIM, I recommend you to read the set of articles about VIM for beginners (one, two, three).

Continue reading “Level up VIM skills”

Weird JavaScript: How Equals Operator Works

Hi, friends. As you know JavaScript is a kind of weird language, at least it seems like for the first time. And what I am going to do is to improve your impression with this category of articles. So welcome to the Weird JavaScript.

And in this first post we are going to talk about equals operator (==). Is there anything can be unclear here? Definitely, everything is understandable for you, just make sure you can answer this questions without any hesitation.

1 == '1'
[] == false
false == {}
NaN == NaN
+0 == -0
null == null
null == undefined
[] == []

If you are not sure in your answers or you just want to get the results, this short post is worth your attention.

Continue reading “Weird JavaScript: How Equals Operator Works”

Das Keyboard Ultimate 4: Brave Decision

Das Keyboard Ultimate 4: Brave Decision

Mechanical keyboards offer a kind of another level of typing experience. These are keyboards which facilitate interaction by providing you a tactile feedback. They are accurate, responsive, extremely durable as long as expensive. Today we are going to speak about a good candidate to be the best mechanical keyboard. Das Keyboard Ultimate 4 which is completely blank with Cherry MX for bad ass coders and gaming enthusiasts.

Continue reading “Das Keyboard Ultimate 4: Brave Decision”

Graphs and trees visualization with DGML

Graphs and trees visualization with DGML

Recently, I had a task to display dependencies between project files according to some rules. I built a tree structure with all necessary information, but the most interesting part was to display it. In this post I will tell you about the easiest solution and maybe the best one I’ve found. If you are interested in, then welcome under the cut.

Continue reading “Graphs and trees visualization with DGML”