Tag Archives: Algorithm

LeetCode – 518. Coin Change 2

You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infinite number of each kind of coin. … Continue reading

Posted in Algorithm&DataStructure, Uncategorized | Tagged , | Leave a comment

LeetCode – 322. Coin Change

You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made … Continue reading

Posted in Algorithm&DataStructure, Uncategorized | Tagged , | Leave a comment

LeetCode – 697. Degree of an Array

Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. Your task is to find the smallest possible length of a (contiguous) subarray of nums, … Continue reading

Posted in Algorithm&DataStructure, Uncategorized | Tagged , , , | Leave a comment

Dynamic Programming Notes

Dynamic programming (also known as dynamic optimization) is a method for solving a complex problem by breaking it down into a collection of simpler sub-problems, solving each of those sub-problems just once, and storing their solutions. The next time the … Continue reading

Posted in Algorithm&DataStructure, Uncategorized | Tagged , | Leave a comment

Advanced Algorithm Research Notes

1. KMP Problem: find a substring in a string brute force: start from every position in str1 and compare with str2, time is O(n*m). optimization idea: position 1 and position 2 comparison is independent. prefix without last one and prefix … Continue reading

Posted in CS Research&Application, Uncategorized | Tagged | Leave a comment

Programming Retrospection (Aug 4)

1. If the problem requirement is very complex, try to convert to simpler one. (In industry, you always get business requirement which is not efficient in technology, you should convert to a tech efficient algorithm/requirement) 标准复杂,就转换标准(蓄水池问题) 在工业界拿到的商业需求可能不是技术上的最优解,这种情况下就要优化需求(把商业需求转换成技术需求)。 2. Tow pointers … Continue reading

Posted in CS Research&Application, Uncategorized | Tagged , , | Leave a comment

Java Basics (Sorting, Classes)

Sorting if same time complexity, check # of swaps # of comparisons o(n^2) Insertion sort > Bubble sort > Selection sort in place (maybe only o(1) space) stable (same numbers’ relative position are same, 2,3,4,5(1),5(2)) o(nlogn) Quick sort o(1) extra … Continue reading

Posted in CS Research&Application, Uncategorized | Tagged , | Leave a comment