自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(26)
  • 问答 (2)
  • 收藏
  • 关注

原创 ECharts使用堆积柱状图时,柱形超出了Y轴最大值

在使用ECharts绘制堆积柱状图时,出现了堆叠的数值超出了Y轴最大值的情况,如下图所示:逐个排查,发现错误原因在于在toolbox中引用了dataZoom:toolbox = { feature: { dataZoom:{ show: false, title:{ dataZoo...

2018-07-19 09:24:22 13083 6

原创 LintCode 152 买卖股票的最佳时机 IV

LintCode 152 买卖股票的最佳时机 IV题目要求: 假设你有一个数组,它的第i个元素是一支给定的股票在第i天的价格。设计一个算法来找到最大的利润。你最多可以完成 k 笔交易。 注意事项: 你不可以同时参与多笔交易(你必须在再次购买前出售掉之前的股票)给出样例如下: 给定价格 = [4,4,6,1,1,4,2,5], 且 k = 2, 返回 6.题目给出的框架如下:

2017-07-13 19:52:55 1772

原创 LintCode 151 买卖股票的最佳时机 III

LintCode 151 买卖股票的最佳时机 III今天做了两道动态规划的题目,感觉对动态规划有了更深入的了解。废话不多说,这是第一道。题目要求如下: 假设你有一个数组,它的第i个元素是一支给定的股票在第i天的价格。设计一个算法来找到最大的利润。你最多可以完成两笔交易。 注意事项: 你不可以同时参与多笔交易(你必须在再次购买前出售掉之前的股票)给出样例如下: 给定价格 = [4

2017-07-13 18:33:42 959

原创 算法概论8.9

算法概论8.9题目要求:在碰撞集(Hitting Set)问题中,给定一组集合{S1,S2,…,Sn}和预算b,我们希望求一个所有的Si相交且规模不超过b的集合H,当然,前提是这样的集合确实存在。换句话说,我们希望对所有的i满足H∩Si≠ϕ。 证明该问题是NP-完全的。证明: 先证明碰撞集问题是一个NP问题 在求解该问题的时候,它需要验证集合H的大小是不是超过b,以及验证对所有的i满足H∩

2017-07-05 17:00:04 398

原创 LeetCode 16. 3Sum Closest

LeetCode 16. 3Sum Closest题目要求:给出一个整型数组nums和一个整数target,要求从nums中找出3个整数a,b,c使得它们的和最接近target。 题目给出的框架如下所示:class Solution {public: int threeSumClosest(vector<int>& nums, int target) { }};解题思路这道题和之

2017-07-05 16:53:38 300

原创 LeetCode 15. 3Sum

LeetCode 15. 3Sum题目要求:给出一个整型数组S。找出里面所有的a,b,c使得a+b+c=0,要求每组数据不能完全相同。 题目给出的框架如下:class Solution {public: vector<vector<int>> threeSum(vector<int>& nums) { }};解题思路3Sum与2Sum的思路是一致的,都是先进行排序,然后采用首尾两

2017-07-05 15:35:07 279

原创 LeetCode 14. Longest Common Prefix

LeetCode 14. Longest Common Prefix题目要求:找出一组字符串中的最长公共前缀。 题目给出的框架如下:class Solution {public: string longestCommonPrefix(vector<string>& strs) { }};解题思路: 采用的是很直接的方法,如果为输入字符串个数为0,则直接返回空字符串,如果只有一个

2017-07-03 23:49:15 193

原创 LeetCode 13. Roman to Integer

Roman to Integer题目要求:给出一个罗马数字,要求转化为整型数字。 题目给出的框架如下:class Solution {public: int romanToInt(string s) { }};先验知识:下面为罗马数字与阿拉伯数字的对照表: 罗马数字 阿拉伯数字 I 1 V 5 X 10 L 50 C 100 D

2017-07-03 23:17:52 215

原创 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轴的线段。求任意两条直线以及x轴形成的最大容器体积。 容器的体积为对应两条线段之间的距离乘以较小的线段长度。解题思路一开始用的是最蠢的方法,即使用双重循环,对任意两条边进行比较,然后华丽

2017-06-28 21:15:09 359

原创 LeetCode 9. Palindrome Number

LeetCode 9. Palindrome Number本题要求判断一个整型变量x是否回文数。具体需要考虑一下几点:负数是否为回文数如果转置的话,是否会出现越界的情况如果要将整型转化为字符串的话,还需要考虑空格的情况题目给出的框架如下:class Solution {public: bool isPalindrome(int x) { }};解题思路方法一:用stack来

2017-06-28 17:39:35 312

原创 LeetCode 7. Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Note:The input is assumed to be a 32-bit signed integer. Your function s

2017-06-12 21:43:34 228

原创 LeetCode 541. Reverse String II

Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of th

2017-06-05 21:00:35 395

原创 LeetCode 500. Keyboard Row

Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.Example 1:Input: ["Hello", "Alaska", "Da

2017-05-15 22:35:35 262

原创 LeetCode 113. Path Sum II

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \

2017-05-01 22:13:52 307

原创 LeetCode 55. Jump Game

题目如下所示:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.

2017-04-24 20:12:06 286

原创 LeetCode 44. Wildcard Matching

Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover t

2017-04-17 21:15:44 248

原创 LeetCode 8. String to Integer (atoi)

Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca

2017-04-10 19:14:08 273

原创 LeetCode 5. Longest Palindromic Substring

Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.

2017-04-03 21:44:43 222

原创 LeetCode 3. Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "

2017-03-26 22:20:56 204

原创 LeetCode 208. Implement Trie (Prefix Tree)

如题所示,要求实现字典树的插入,查找单词,和查找前缀的方法。Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase letters a-z.Subscribe to see

2017-03-19 23:53:18 237

原创 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:Integers in each row are sorted in ascending from left to right.Integers in

2017-03-12 21:36:40 314

原创 LeetCode 215. Kth Largest Element in an Array

Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, return 5.

2017-03-05 21:12:31 351

原创 LeetCode 116 Populating Next Right Pointers in Each Node

Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node.

2016-10-16 13:01:26 336

原创 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 ordered from top to bottom.For example:Given the following binary tree, 1

2016-10-16 11:19:15 378

原创 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 the path equals the given sum.For example:Given the below binary tree and sum

2016-10-15 17:14:22 228

原创 LeetCode 88. Merge Sorted Array

Merge Sorted Array的意思是将两个有序的数组nums1和nums2合并成为一个有序的数组nums1。原题如下:class Solution {public: void merge(vector& nums1, int m, vector& nums2, int n) { }};思路如下:对nums1的元素从尾部开始进行移动操

2016-09-26 23:25:24 308

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除