Marcy Blog

Failed to be a geek

S.O.L.I.D in Ruby

“Ruby is the best object-oriented language.. if you use it in the right way” For a long time working in the Ruby world, primarily working on Ruby on Rails projects, I found many projects do no...

Scrum: A powerful Agile framework

“Let’s do scrum” Scrum is a very useful Agile framework and works very well especially with Ruby on Rails stack. In this post we will give a detail introduction about what scrum is and how to ...

ActiveRecord Optimization

Optimizing performance by using ActiveRecord properly

“Rails could be not that slow…” Better Rails: ActiveRecord Optimization All web applications need to interact with databases and ActiveRecord makes it so easy. With the default .where and ....

Hello 2018

"Hello World, Hello Blog"

“Hello 2018” About 2017 Today is Feb 16, 2018, the Chinese New Year. 2017 was kind of frustrating to me. I started the year by building my own startup but it did not have much progress. My ...

Problem: Longest Word in Dictionary

Question Given a list of strings words representing an English Dictionary, find the longest word in words that can be built one character at a time by other words in words. If there is more than o...

Problem: Implement a Trie

Solution TODO Code class Trie { class TrieNode { TrieNode[] nodes = new TrieNode[26]; char c; boolean end; } TrieNode root = new TrieNode(); /**...

An Easy Way to Understand Algorithm Complexity and Big O Notation

Big O notation is the most widely used method which describes algorithm complexity – the execution time required or the space used in memory or disk by an algorithm. Often in exams or interviews, y...

Problem: Logger Rate Limiter

Question Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in the last 10 seconds. Given a message ...

Problem: Roman to Integer

Question Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 ...

Problem: Shuffle an Array

Question Shuffle a set of numbers without duplicates. Example: // Init an array with set 1, 2, and 3. int[] nums = {1,2,3}; Solution solution = new Solution(nums); // Shuffle the array [1,2,3] a...