Monthly Archives: September 2015


[leetcode] H-Index

H-Index Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher’s h-index. According to the definition of h-index on Wikipedia: “A scientist has index h if h of his/her N papers have at leasth citations each, and the other […]


[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++ 2

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 […]