03 2018 档案

摘要:一、 STL函数 lower_bound() 试图在已排序的 [first, last) 中寻找元素 value。返回一个迭代器,指向第一个“不小于 value”的元素,如果 value 大于 [first, last)内的任何一个元素,则返回 last。实际上,它返回“在不破坏顺序的情况下,可插入 阅读全文
posted @ 2018-03-31 21:36 Vincent丶丶 阅读(1103) 评论(0) 推荐(0) 编辑
摘要:一、哈夫曼树 1. 哈夫曼树也称最优二叉树。 叶子节点的权值是对叶子节点赋予的一个有意义的数值量。 设二叉树具有 n 个带权值的叶子结点,从根节点到各个叶子结点的路径长度与相应叶子结点权值的乘积之和叫做二叉树的带权路径长度。 给定一组具有确定权值的叶子结点,可以构造处不同的二叉树,将其中带权路径长度 阅读全文
posted @ 2018-03-29 21:26 Vincent丶丶 阅读(17771) 评论(0) 推荐(3) 编辑
摘要:最小生成树概念: 给定一个无向图,如果它的某个子图中任意两个顶点都互相连通并且是一颗树,那么这棵树就称为生成树。如果边上有权值,那么使得边权和最小的生成树就叫做最小生成树(MST)。 常用算法:Prim 算法, Kruskal算法 Prim 算法 Prim算法与Dijkstra算法十分相似,基于贪心 阅读全文
posted @ 2018-03-26 12:17 Vincent丶丶 阅读(224) 评论(0) 推荐(0) 编辑
摘要:1. Next Permutation 首先,从最尾端开始往前寻找两个相邻元素,令第一元素为 *i,第二元素为 *ii,且满足 *i < *ii;找到这样一组相邻元素后,再从尾端开始往前检验,找出第一个大于 *i 的元素,令为 *j,将 i,j 元素对调,再将 ii 之后的所有元素颠倒排列。 2.P 阅读全文
posted @ 2018-03-26 10:17 Vincent丶丶 阅读(486) 评论(0) 推荐(0) 编辑
摘要:Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 题解: 思路就是被除数减去除数,减尽为止。优化的方法是尽量少的做减法。由于不 阅读全文
posted @ 2018-03-26 00:42 Vincent丶丶 阅读(175) 评论(0) 推荐(0) 编辑
摘要:Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Example 2: 题解: 阅读全文
posted @ 2018-03-25 23:42 Vincent丶丶 阅读(136) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to 阅读全文
posted @ 2018-03-25 23:17 Vincent丶丶 阅读(178) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as 2->1->4->3. Your a 阅读全文
posted @ 2018-03-25 22:07 Vincent丶丶 阅读(142) 评论(0) 推荐(0) 编辑
摘要:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 题解: 归并思想。 Solution 1 Solution 2 利用最小堆,c++的优先队列prior 阅读全文
posted @ 2018-03-25 21:56 Vincent丶丶 阅读(138) 评论(0) 推荐(0) 编辑
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example: 阅读全文
posted @ 2018-03-25 20:41 Vincent丶丶 阅读(164) 评论(0) 推荐(0) 编辑
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the 阅读全文
posted @ 2018-03-25 20:34 Vincent丶丶 阅读(119) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, remove the nth node from the end of list and return its head. For example, Note:Given n will always be valid.Try to do this in on 阅读全文
posted @ 2018-03-25 20:06 Vincent丶丶 阅读(141) 评论(0) 推荐(0) 编辑
摘要:Write a function to find the longest common prefix string amongst an array of strings. 题解: 简单的暴力遍历解决 阅读全文
posted @ 2018-03-25 17:04 Vincent丶丶 阅读(141) 评论(0) 推荐(0) 编辑
摘要:Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. Given an integer, convert it to a roman nu 阅读全文
posted @ 2018-03-25 16:51 Vincent丶丶 阅读(158) 评论(0) 推荐(0) 编辑
摘要:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. Given a roman numeral, convert it to an in 阅读全文
posted @ 2018-03-25 16:23 Vincent丶丶 阅读(208) 评论(0) 推荐(0) 编辑
摘要:Implement regular expression matching with support for '.' and '*'. 题解: 这种题是最无语的。。。我试着用遍历做,当 s 为空,p 不为空时的判定怎么也总结不出规律了。还是得用递归做 注意 ’*‘ 之前必须有字符供其匹配。s = " 阅读全文
posted @ 2018-03-25 15:56 Vincent丶丶 阅读(181) 评论(0) 推荐(0) 编辑
摘要:Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thi 阅读全文
posted @ 2018-03-25 14:04 Vincent丶丶 阅读(164) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2018-03-25 13:40 Vincent丶丶 阅读(192) 评论(0) 推荐(0) 编辑
摘要:Given a 32-bit signed integer, reverse digits of an integer. Example 1: Example 2: Example 3: Note:Assume we are dealing with an environment which cou 阅读全文
posted @ 2018-03-25 11:30 Vincent丶丶 阅读(129) 评论(0) 推荐(0) 编辑
摘要:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font 阅读全文
posted @ 2018-03-25 10:59 Vincent丶丶 阅读(207) 评论(0) 推荐(0) 编辑
摘要:Manacher's Algorithm针对的是最长回文子串问题。对于此问题,最直接的方法是遍历每一个元素,遍历过程中以每一个字符为中心向两边扩展以寻找此字符为中心的最长回文子串。复杂度O(n2)。Manacher算法将时间复杂度降至O(n),关键点在于将奇偶字串统一成奇数字串。 方法是在每一个字符 阅读全文
posted @ 2018-03-25 09:20 Vincent丶丶 阅读(224) 评论(0) 推荐(0) 编辑
摘要:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: Example: 题解: Solution 1 暴 阅读全文
posted @ 2018-03-24 13:33 Vincent丶丶 阅读(232) 评论(0) 推荐(0) 编辑
摘要:Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng 阅读全文
posted @ 2018-03-24 01:01 Vincent丶丶 阅读(154) 评论(0) 推荐(0) 编辑
摘要:节点定义如下 前序遍历: 若二叉树为空,则空操作返回,否则: 中序遍历: 若二叉树为空,则空操作返回,否则: 后序遍历: 若二叉树为空,则空操作返回,否则: 层序遍历: 其中后序遍历可以看作是和前序遍历是对称的,所以从根节点开始先遍历右子树,再遍历左子树,不过要把最后的遍历输出翻转过来。所以后序遍历 阅读全文
posted @ 2018-03-17 09:13 Vincent丶丶 阅读(424) 评论(0) 推荐(0) 编辑
摘要:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, 阅读全文
posted @ 2018-03-16 21:15 Vincent丶丶 阅读(180) 评论(0) 推荐(0) 编辑
摘要:自定义排序需要单独写一个compare函数 例1 LeetCode 056. Merge Intervals Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6] 阅读全文
posted @ 2018-03-15 22:04 Vincent丶丶 阅读(7020) 评论(0) 推荐(0) 编辑
摘要:我们有时想把变量放进正则表达式中来匹配想要的结果。Python中使用 re.compile(r''+变量+''),其中正则表达式中的“变量”应为字符串形式。 得到结果 可以看到,Python是将正则表达式用字符串表示的,格式为 r'正则表达式 ' 正则表达式使用变量例子: 结果为 附正则表达式语法: 阅读全文
posted @ 2018-03-09 20:43 Vincent丶丶 阅读(14582) 评论(0) 推荐(0) 编辑
摘要:1.双y轴绘制 关键函数:twinx() 问题在于此时图例会有两个。 每个句柄对应一个图例。 2. 合并图例 1) 仅使用一个轴的legend()函数 可以看到y1轴和y2轴的图例已经合并了 2)使用figure.legend() 可以看到图例位置不对,已经出界,需要使用bbox_to_anchor 阅读全文
posted @ 2018-03-08 20:39 Vincent丶丶 阅读(103391) 评论(1) 推荐(7) 编辑

点击右上角即可分享
微信分享提示