Home

Awesome

Algorithms

Algorithms playground for common questions solved in ruby syntax.
In case you want to prepare yourself for a job interview - try to solve it yourself first, then have a look here.

Why?

I interviewed with Google, Facebook, LinkedIn, Twitter and others. I also interviewed others myself. Sometimes it looks like they all ask you the same "out of the box" questions that don't really check knowledge but memorization of the same tricks. This is my way of saying - change your interview style. There are lots of smart people out there, this is not the best way to find them.

Problems

problemsolution
Unique binary search treesclick
House Robberclick
Decode Waysclick
Coin changeclick
Decode Stringsclick
Wiggle Subsequenceclick
Binary Tree Side Viewclick
Unix pathclick
Array Productclick
Top K Frequent Elementsclick
Sum 4 arraysclick
Reverse Linked Listclick
Reverse String In-placeclick
Nested List Weight Sum IIclick
Symmetric Treeclick
Dijkstra's shortest path between two nodesclick
Kruskal's minimum spanning tree algorithmclick
Find the square root of a numberclick
Add two binary numbersclick
Binary searchclick
Longest increasing subsequenceclick
Find all permutations of arrayclick
Finding all combinations of well-formed bracketsclick
Finding the powerset of a setclick
Game of lifeclick
Print all combinations of set joiningclick
count and sayclick
Telephone number to wordsclick
Maximum contiguous subarrayclick
Max Stackclick
Find the smallest biggest number that has the same digitsclick
Find the minimum insertions needed to make a word palindromeclick
String matching - Knuth Morris Pratt algorithm KMPclick
Balanced Parenthesesclick
Quicksort algorithmclick
Mergesort algorithmclick
Max Stocks Profitclick
Countingsort algorithmclick
Shellsort algorithmclick
Knapsack problemclick, click
Move Zeroesclick
Longest common subsequence problemclick , click
Monty Hall Problemclick
Eucliden and Extended Eucliden algorithmclick
Suggest index of a number in an arrayclick
Range minimum query sparse table algorithmclick
Insertion Sortclick
Towers of Hanoi using Stackclick
Tarjan's strongly connected components finderclick

How?

Simply run ruby some_file.rb to execute the algorithm. At the bottom of each file there are some test samples.
example: ruby brackets_combinations.rb will print:
["((()))", "(()())", "(())()", "()(())", "()()()"].

Contribute

Did you find a bug? any way to do it better? please feel free to pull-request it :)