1. Description Recursive way is based on computer program, the function calling stack. While iterative way is programmer use stack to simulate it. 2. Solution

Read More1. Description Recursive way is based on computer program, the function calling stack. While iterative way is programmer use stack to simulate it. 2. Solution

Read More1. Description Given an integer, return its base 7 string representation. 2. Example 3. Solution 4. Complexity Time: O(n) Space: O(1)

Read More1. Description Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit. Note that you cannot sell a stock […]

Read More1. Description Give a pattern and a string, and check if the string follows the pattern. 2. Example 3. Solution 3.1 Wrong solution First, I was thinking, if I can use the AscII code to represent the pattern. For example: hello -> ‘a’, and hello -> ‘a’, world -> ‘b’, world->’b’. Use the data structure […]

Read MoreJava Utils Class, Arrays and Collections, including the commonly used methods.

Read MoreHow to play dice game? Try this challenging, you will learn a lot of using ArrayList and Loop.

Read MoreA BST is a rooted binary tree, whose internal nodes each store a key, and each have two distinguished subtrees, commonly denoted left and right.

Read MoreBinary search is an efficient algorithm for finding an item from a sorted list of items. Here you will find several morphs with the source code.

Read MoreGive a list of sorted numbers, delete all duplicates such that each element appear only once. Time complexity must be in O(n).

Read MoreSorting is really important in software development. This article brings the four sort algorithms, which are Bucket Sort, Bubble sort, selection sort and quick sort.

Read More