Playing with Palindromes – Part 1

Today I'll show some problems involving palindromes: The first problem is stated as followed: "Given a string S, return the minimum number of characters required to be deleted from S, in order to turn it into a Palindrome". By definition, the minimum characters solution will give us also the maximal size palindrome, but lets focus…


If you wanna get sh** done … Python is there for your rescue.

How I wish life could be automated. Well, at least the boring parts of it. I recently realized that if every aspect of life could be automated, Python would have been my language of choice to do so. No, you won't hear from me in this post how Python is the best language I've encountered.You…


Permutation Sequence (LintCode)

Today I'll show a solution to another nice problem from LintCode: Permutation Sequence.  The description of this problem is as followed:   As the description says, the most intuitive way to solve this problem is to start enumerating all permutation until we reach the K'th one. However, this would make the problem not very interesting….


Building an Expression Tree

I recently solved a problem in yet another online judge website (LintCode) which asked to build an expression tree from an infix expression. I found this problem to be quite challenging and not as straightforward as I originally anticipated. Hence, I'm dedicating this post to it. To start lets define an expression tree. This is a…


Yet another case of a weak hypothesis.

We have seen many problems for which induction was used (based on Manber's book) to device an Algorithm for them. However, many times the problem is not easily solved (as is) and it is hard to find the correct hypothesis as well as the correct reduction in size to solve it. In such cases it is…


Find The smallest Number that can be created by a string of digits`

The following fun problem is defined as followed: Given a string of digits S and a number K, return the smallest integer number that can be created by deleting K digits from S while preserving the relative locations of the digits.   As an example Lets assume S = "914123107" and K = 3, the…


Trap Rain Water Problem

The following problem is taken from yet another coding challenges web site named LeetCode. This is a fun problem to solve and to show a nice divide and conquer approach to its solution. Lets see how we can solve this problem using the famous induction approach. Our induction will be on the number of bars….


Hackerrank – Chief Hopper problem

In This post I would like to discuss a nice problem that I solved recently in Hackerrank. For those of you who don't know Hackerrank, then it is time to get acquainted with it. Its a great site containing many coding challenges with an online judge. The Challenges are divided into categories (graphs, dynamic programming, greedy, etc…)…


Radix Sort – sorting has never been so fun

Today I'll discuss Radix Sort. The reason I chose to write about Radix Sort is that despite the fact that I learnt it in the past, unlike other sorting algorithms such as Merge Sort  and Quick Sort I was never able to remember how it worked and what were its advantages. Recently I decided to relearn it,…