原创 [面試算法] 劍指Offer代碼彙總
此博客彙總劍指offer上的部分代碼,更新中.......6.重建二叉樹(前序和中序)TreeNode* reConstructBinaryTree(vector<int> pre, vector<int> vin) { if (
原创 [Leetcode] #204 Count Primes
DiscriptionCount the number of prime numbers less than a non-negative number, n.Solutionint countPrimes(int n){ //埃拉託斯
原创 [Leetcode] #542 01 Matrix (BFS)
DiscriptionGiven a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.The distance between tw
原创 [Leetcode] #537 Complex Number Multiplication(stringstream)
DiscriptionGiven two strings representing two complex numbers.You need to return a string representing their multiplica
原创 [面試算法] 01揹包 & 完全揹包
Discription小Ho現在手上有M張獎券,而獎品區有N件獎品,分別標號爲1到N,其中第i件獎品需要need(i)張獎券進行兌換,同時也只能兌換一次,爲了使得辛苦得到的獎券不白白浪費,小Ho給每件獎品都評了分,其中第i件獎品的評分值爲
原创 [Leetcode] #97 Interleaving String
DiscriptionGiven s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",
原创 [Leetcode] #263#264 Ugly Number I & II
DiscriptionWrite a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose pr
原创 [面試算法] 排序算法
快速排序int partion(vector<int> &nums, int begin, int end){ int x = nums[end], i = begin - 1; for (int j = begin; j < end
原创 [Leetcode] #139 Word Break
DiscriptionGiven a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s ca
原创 [Leetcode] #79 Word Search
DiscriptionGiven a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of
原创 [面試算法] 動態規劃
LCS(最長公共子序列)int LCS(string s1, string s2){ int len1 = s1.size(), len2 = s2.size(); vector<vector<int>> lcs(len1 + 1,
原创 [Leetcode] #313 Super Ugly Number
DiscriptionWrite a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime fa
原创 [Leetcode] #290 Word Pattern (map,sstream)
DiscriptionGiven a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such
原创 [Leetcode] #134 Gas Station
Discription: There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You ha
原创 [Leetcode] #347 Top K Frequent Elements
Discription: Given a non-empty array of integers, return the k most frequent elements. For example, Given [1,1,1,2,2