Daily Archives: September 24, 2015


[leetcode] Move Zeroes

Move Zeroes Given an array nums, write a function to move all 0‘s to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0]. Note: […]


[leetcode] Peeking Iterator

Peeking Iterator Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation — it essentially peek() at the element that will be returned by the next call to next(). Here is an example. Assume that the iterator is initialized to […]


How to Generate a Maze in C++

Generating maze is amazing! This algorithm is also widely used in lots of computer games. Given a 2D array, generate a maze in it. There are several requirements of this maze: There are no circles in the maze, which means all roads in the maze lead to an dead end or to […]