# Posts by: Nicholas Wong

## Awesome New Layout!

Well, it is always good to have a refreshing layout. I spent like 2 days to tweak my website layout. It's really awesome. Useless widgets are removed and background changed.…

## Happy Android Development with Gradle

Recently I have been working a lot on migrating android projects to use gradle building system. Seriously it is much better than the old time. I can easily use libraries…

## Interview Practice Extra 07 – Universal Value Binary Tree

Question Design an algorithm to verify that a tree is a universal value binary tree. Universal value binary tree means all value in that tree is the same. Solution There is…

## Interview Practice Extra 06 – Vending Machine

Question This is an actual question I encountered in an Amazon phone interview in November 2013. You are going to design the money changing algorithm for a vending machine. That…

## Interview Practice Extra 05 – Identify Prime Numbers

Question Write an algorithm to identify prime numbers from a list of numbers ranging 0-100. Solution The main question is actually to write a program to check if a number…

## Interview Practice Extra 04 – Remove Node from Singly Linked List

Question How do you remove a node from a singly linked list, given only that node? Head node is not given. Solution Set next of this node to the next…

## Interview Practice 28 – Counting One in Binary Expression

Question Given a number, find the number of 1 in the number's binary expression. For example, binary express of 10 is 1010. So the number of 1 in it is 2.…

## Interview Practice 26 – String Right-rotation

Question Write a program to right-rotate a string by m characters. Right-rotating a string means moving m characters at the left of string to the right. Is it required the…

## Interview Practice 25 – Longest Consecutive Digits

Question Given a function prototype: int continumax(char *output_string,char *input_string). Implement it to find the longest consecutive digits. This function must return the length of the longest digits. The found longest…

## Interview Practice 24 – Reverse a Linked List

Question Reverse a linked list. Sample [crayon-535820e6548ee248369460/]

## Interview Practice 22 – Card Guessing

Question Consider there are 4 blue and 4 red cards. Host gets 2 cards randomly, no one knows what cards they are. Then he places 2 random cards at the…

## Interview Practice 21 – Summing Combinations

Question Given a integers m and n, generate all combination within 1 to n that would give the sum m. For example, for m=5 and n=5, the combinations are {5}, {4+1},…

## Interview Pizzle 1 – Find the Heavier Marble

Question You have 9 marbles. 8 marbles weigh 1 ounce each, & one marble weighs 1.5 ounces. You are unable to determine which is the heavier marble by looking at them. You…

## Interview Practice 20 – Convert String to Integer

Question Convert the inputted string to an integer. For example, "345" will output 345. Solution Though it looks simple, in fact it is pretty tricky. First we need to make…

## Interview Practice 19 – Fastest Way to Calculate Fibonacci Sequence

Question Construct an algorithm so that the Nth item of  Fibonacci Sequence can be found in the shortest time. Definition of Fibonacci Sequence is: [crayon-535820e658569781704183/] Solution There are many solutions for this,…

## Interview Practice 18 – Last Surviving Number in Loop

Consider Consider there is a list containing N numbers, and which formed a ring. That is, item n+1 is item 1. Construct an algorithm such that it traverses through the…

## Interview Practice 17 – Find The String Appeared Once

Question Given a string, write an algorithm to find the character inside that appeared only once. For example, the result for string "abaccdeff" is b. Solution We can use a…

## Interview Practice Extra 03 – Verify Binary Tree with Same Value

Question Verify whether all nodes have the same value in a binary tree. Solution We can traverse the tree with our usual way, like depth-first or breadth-first algorithm. Then pass…

## Interview Practice Extra 02 – Duplicates in List

Question Write an algorithm to remove duplicated node from a linked list. Solution There are many ways to do it. For the first one, as the simplest one, we could…

## Interview Practice Extra 01 – Find Loop in Linked List

Question Validate a linked list whether there is a loop in it. That is, there is a node in a linked list with  the next pointer pointing to a node…