1. 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 Given an integer, return its base 7 string representation. 2. Example 3. Solution 4. Complexity Time: O(n) Space: O(1)

Read More1. Description Asked by Google. Given a list of numbers and a number k, return whether any two numbers from the list add up to k. 2. Example Given [10, 15, 3, 7] and k of 17, return true, since 10+7 is 17. 3. Solution – 3 ways to solve it.

Read More1. Description Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too. You need to find the shortest such subarray and output its length. Example 1: Input: [2, 6, 4, 8, 10, 9, 15] Output: 5 Explanation: […]

Read MoreApache Struts is a free, open-source, MVC framework for creating elegant, modern Java Web applications. This post introduces an app implement by Struts + Hibernate.

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 More1. Questions What’s the best/worst running time of Merge Sort? O(nlogn), O(nlogn) What’s the best/worst running time of Quick Sort? O(n), O(n^2) What’s the worst running time for a look up in a HashTable? O(n) two reasons: if too many elements were hashed into the same key: looking inside this key may take O(n) time; […]

Read MoreGraph data structure is import. One main application is social media, like twitter and facebook. Twitter uses undirected graph, while facebook using Directed graph.

Read MoreLeetCode, check if an array contains duplicated value in it. Apply Java Set feature to solve it.

Read More1. Problem Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. 2. Examples 3. Solution Two possible solutions, I think I can solve this problem. #1. Use Java built-in […]

Read More