原创 LeetCode 112. Path Sum

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along

原创 LeetCode 88. Merge Sorted Array

Merge Sorted Array的意思是將兩個有序的數組nums1和nums2合併成爲一個有序的數組nums1。 原題如下: class Solution { public: void merge(vector<int>&

原创 LeetCode 199.Binary Tree Right Side View

Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ord

原创 LeetCode 240. Search a 2D Matrix II

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:

原创 LeetCode 9. Palindrome Number

LeetCode 9. Palindrome Number 本題要求判斷一個整型變量x是否迴文數。具體需要考慮一下幾點: 負數是否爲迴文數 如果轉置的話,是否會出現越界的情況 如果要將整型轉化爲字符串的話,還需要考慮空格的情況 題目給

原创 LeetCode 13. Roman to Integer

Roman to Integer 題目要求:給出一個羅馬數字,要求轉化爲整型數字。 題目給出的框架如下: class Solution { public: int romanToInt(string s) { } };

原创 算法概論8.9

算法概論8.9 題目要求:在碰撞集(Hitting Set)問題中,給定一組集合{S1,S2,…,Sn}和預算b,我們希望求一個所有的Si相交且規模不超過b的集合H,當然,前提是這樣的集合確實存在。換句話說,我們希望對所有的i滿足H∩Si

原创 ECharts使用堆積柱狀圖時,柱形超出了Y軸最大值

在使用ECharts繪製堆積柱狀圖時,出現了堆疊的數值超出了Y軸最大值的情況,如下圖所示: 逐個排查,發現錯誤原因在於在toolbox中引用了dataZoom: toolbox = { feature: { d

原创 LeetCode 16. 3Sum Closest

LeetCode 16. 3Sum Closest 題目要求:給出一個整型數組nums和一個整數target,要求從nums中找出3個整數a,b,c使得它們的和最接近target。 題目給出的框架如下所示: class Solution

原创 LintCode 151 買賣股票的最佳時機 III

LintCode 151 買賣股票的最佳時機 III 今天做了兩道動態規劃的題目,感覺對動態規劃有了更深入的瞭解。廢話不多說,這是第一道。題目要求如下: 假設你有一個數組,它的第i個元素是一支給定的股票在第i天的價格。設計一個算法來找到

原创 LintCode 152 買賣股票的最佳時機 IV

LintCode 152 買賣股票的最佳時機 IV 題目要求: 假設你有一個數組,它的第i個元素是一支給定的股票在第i天的價格。設計一個算法來找到最大的利潤。你最多可以完成 k 筆交易。 注意事項: 你不可以同時參與多筆交易(你

原创 LeetCode 15. 3Sum

LeetCode 15. 3Sum 題目要求:給出一個整型數組S。找出裏面所有的a,b,c使得a+b+c=0,要求每組數據不能完全相同。 題目給出的框架如下: class Solution { public: vector<ve

原创 LeetCode 14. Longest Common Prefix

LeetCode 14. Longest Common Prefix 題目要求:找出一組字符串中的最長公共前綴。 題目給出的框架如下: class Solution { public: string longestCommonP

原创 LeetCode 7. Reverse Integer

Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 click to show spoilers.

原创 LeetCode 11. Container With Most Water

LeetCode 11. Container With Most Water 題目要求:給出n個非負的整數a1,a2,… an。分別得到n個點(i,ai)。每個點(i,ai)與x軸上對應的點(i,0)組成一條垂直於x軸的線段。求任意兩條直