自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(122)
  • 收藏
  • 关注

原创 leetcode 14. 最长公共前缀

题目:编写一个函数来查找字符串数组中的最长公共前缀。如果不存在公共前缀,返回空字符串 “”。示例 1:输入: [“flower”,“flow”,“flight”]输出: “fl”示例 2:输入: [“dog”,“racecar”,“car”]输出: “”解释: 输入不存在公共前缀。来源:力扣(LeetCode)链接:https://leetcode-cn.com/prob...

2019-09-03 16:08:05 145

原创 最长回文子串

题目给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。示例 1:输入: “babad”输出: “bab”注意: “aba” 也是一个有效答案。示例 2:输入: “cbbd”输出: “bb”来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/longest-palindromic-subs...

2019-08-30 14:25:52 233

原创 无重复字符的最长子串

题目给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。示例 1:输入: “abcabcbb”输出: 3解释: 因为无重复字符的最长子串是 “abc”,所以其长度为 3。示例 2:输入: “bbbbb”输出: 1解释: 因为无重复字符的最长子串是 “b”,所以其长度为 1。示例 3:输入: “pwwkew”输出: 3解释: 因为无重复字符的最长子串是 “w...

2019-08-30 13:09:43 195

原创 longest-consecutive-sequence

题目:给定一个无序的整数类型数组,求最长的连续元素序列的长度。例如:给出的数组为[100, 4, 200, 1, 3, 2],最长的连续元素序列为[1, 2, 3, 4]. 返回这个序列的长度:4你需要给出时间复杂度在O(n)之内的算法 Given an unsorted array of integers, find the length of the longest cons...

2019-08-15 17:35:09 190

原创 palindrome-partitioning

题目:给定一个字符串s,分割s使得s的每一个子串都是回文串返回所有的回文分割结果例如:给定字符串s=“aab”,返回[↵ [“aa”,“b”],↵ [“a”,“a”,“b”]↵ ]Given a string s, partition s such that every substring of the partition is a palindrome.Retur...

2019-08-14 22:50:54 128

原创 palindrome-partitioning-ii

题目: 给出一个字符串s,分割s使得分割出的每一个子串都是回文串 计算将字符串s分割成回文分割结果的最小切割数 例如:给定字符串s="aab", 返回1,因为回文分割结果["aa","b"]是切割一次生成的。 Given a string s, partition s such that every substring of the partition is a pa...

2019-08-14 20:10:47 137

原创 gas-station

题目:There are N gas stations along a circular route, where the amount of gas at station i isgas[i].You have a car with an unlimited gas tank and it costscost[i]of gas to travel from station i to it...

2019-08-09 16:20:40 132

原创 candy

题目:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on...

2019-08-06 22:38:57 109

原创 single-number-ii

题目:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without u...

2019-08-06 15:08:25 151

原创 word-break

题目:Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens =“leetcode”,dict =[“leet”,...

2019-08-05 20:51:47 124

原创 resnet v2

相比resnet v1,主要修改了bn层与relu层的顺序残差块公式yl=h(xl)+F(xl,wl)xl+1=f(yl)y_l = h(x_l) + F(x_l, w_l) \\x_{l+1} = f(y_l)yl​=h(xl​)+F(xl​,wl​)xl+1​=f(yl​)分析其中图(1)为Resnet v1的残差块图,图(5)为ResNet v2的残差块在ResNet...

2019-08-01 15:05:32 282

原创 最大乘积

题目:给定一个无序数组,包含正数、负数和0,要求从中找出3个数的乘积,使得乘积最大,要求时间复杂度:O(n),空间复杂度:O(1)输入描述:无序整数数组A[n]输出描述:满足条件的最大乘积示例1输入3 4 1 2输出24idea:由于数组中包含整数、负数和0,那么最大的乘积有两种可能:(1)最大的三个正数 (2)最大的一个正数、最小的两个负数冒泡分别求出最大的三个正...

2019-07-22 20:13:55 218

原创 使用frp在外网进行内网穿透访问内网jupyter

动机:一直以来一直使用teamviewer访问实验室电脑,再通过实验室电脑访问服务器。非常麻烦,于是想通过jupyter直接远程访问服务器python解释器。你需要的:一个拥有公网ip的云服务器以及开源工具frp 点击进入下载链接方法分别在公网云服务器和内网服务器分别下载frp并解压缩,命令为tar -zxvf frp_0.27.1_linux_amd64.tar.gz在公网云服务器...

2019-07-20 00:16:13 1035 1

原创 word-break-ii

题目:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, givens =“cat...

2019-07-16 22:21:16 163

原创 linked-list-cycle

题目:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?idea:使用快慢指针,假如快指针追上慢指针fast==slow,则存在cycle。如果fast为空则不存在cycle。code/** * Defin...

2019-07-14 21:33:25 79

原创 非极大值抑制(NMS)

NMS:常用于目标检测中,将候选框中与高分候选框重合度大于某一阈值的候选框去掉。算法流程:令filter_boxes为待筛选的候选框的集合,初始化为所有候选框。令chosen_boxes为已经入选的候选框集合,初始化为空。对filter_boxes根据预测概率从高到底进行排序。遍历filter_boxes将filter_boxes中概率最高的filter_boxes[0]放入c...

2019-07-12 16:56:38 322

原创 长度为1的线段,随机在其上选择两点,将线段分为三段,问这3段能组成一个三角形的概率是多少

idea:直接上三维,可行域是x+y+z=1,    0&lt;x,y,z&lt;1x+y+z=1, \ \ \ \ 0&lt;x,y,z&lt;1x+y+z=1,    0<x,y,z<1显然,可行域与我的博客一条长度为1的线段,随机剪两刀,求有一根大于0.5的概率问题...

2019-07-12 15:23:38 5633

原创 一条长度为1的线段,随机剪两刀,求有一根大于0.5的概率。

idea:直接画图…二维解法,令x为第一段长度,y为第二段长度,则x、y确定后,第三段长度z也确定了。可行域:x+y&lt;1,x&gt;0,y&gt;0x+y&lt;1,x&gt;0,y&gt;0x+y<1,x>0,y>0解空间:x&gt;0.5,y&gt;0.5,x+y&lt;0.5x&a...

2019-07-12 14:49:09 1854

原创 linked-list-cycle-ii

题目:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?idea:使用快慢指针,快指针每次走两步,慢指针每次走一步假设慢指针走了(...

2019-07-11 20:50:54 158

原创 reorder-list

题目:Given a singly linked list L: L 0→L 1→…→L n-1→L n,reorder it to: L 0→L n →L 1→L n-1→L 2→L n-2→…You must do this in-place without altering the nodes’ values.For example,Given{1,2,3,4}, reorder...

2019-07-10 21:32:48 73

原创 binary-tree-preorder-traversal

题目:Given a binary tree, return the preorder traversal of its nodes’ values.For example:Given binary tree{1,#,2,3},12/3return[1,2,3].Note: Recursive solution is trivial, could you do it iter...

2019-07-10 20:46:09 106

原创 binary-tree-postorder-traversal(二叉树后序遍历)

题目:Given a binary tree, return the postorder traversal of its nodes’ values.For example:Given binary tree{1,#,2,3},12/3return[3,2,1].Note: Recursive solution is trivial, could you do it ite...

2019-07-10 20:33:35 115

原创 insert-sort-list

题目:Sort a linked list using insertion sort.idea:直接新建一个链表,遍历原链表每一个结点p,从头开始遍历新链表,当p的值小于等于new_p(新链表指针)的值时,将prev的next指向p,p指向new_p。code/** * Definition for singly-linked list. * struct ListNode { *...

2019-07-10 20:01:17 95

原创 sort-list

题目:sort a linked list in O(n log n) time using constant space complexity.idea:使用自底向上来归并排序链表,首先将左右两个待合并的链表分别cut切开,即将左右两个链表的结尾节点的next设置为NULL每次合并完两个链表以后将上一个合并完的链表的尾部的next指向当前合并完的链表code:/** * ...

2019-07-09 14:32:46 127

原创 pytorch不同行取不同列的元素

使用内置函数gather即可demot是一个4*3的tensor,第0行取出第0个元素,第1行取出第三个元素。注意idx是long类型

2019-06-27 20:16:40 3953 2

原创 SVM总结

线性可分SVM1. 概念分离超平面w∗⋅x+b∗=0        (1)w^{*} \cdot x+b^{*}=0 \ \ \ \ \ \ \ \ (1)w∗⋅x+b∗=0        (1)分类决策函数f(x)=si...

2019-06-19 21:52:03 127

原创 max-points-on-a-line

题目:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.idea两点确定一条直线,使用斜率来标记一条直线(以及当前遍历的点)特殊情况:两个点重复时,该点的任意一条直线上的点都应该+1。因此用一个变量dup来保存于当前点重复的点当直接垂...

2019-05-27 20:21:57 95

原创 视频超分辨率论文笔记:Recurrent Back-Projection Network for Video Super-Resolution

Recurrent Back-Projection Network for Video Super-Resolution - CVPR2019paper:https://arxiv.org/pdf/1801.04590v4.pdfcode:https://github.com/alterzero/RBPN-PyTorch1. Related Work与DBPN论文一样,都是先总结并...

2019-05-24 16:32:08 3042 5

原创 视频超分辨率论文笔记:Deep Back-Projection Networks For Super-Resolution

Deep Back-Projection Networks For Super-Resolution:CVPR 2018paper:https://arxiv.org/pdf/1803.02735v1.pdfcode:https://github.com/alterzero/DBPN-Pytorch1. Relative workintro里边提到目前图像SR(超分辨率)的DL模型的四种...

2019-05-23 23:28:25 912

原创 evaluate reverse-polish notation

题目:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are+,-,,/. Each operand may be an integer or another expression.Some examples:[“2”, “1”, “+”, “3”, ""]...

2019-04-29 15:19:15 93

原创 minimum-depth-of-binary-tree

题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.idea:层次遍历,找到第一个叶子节点时返回当前深度。code#in...

2019-04-29 14:31:50 78

原创 机器人的运动范围

题目:地上有一个m行和n列的方格。一个机器人从坐标0,0的格子开始移动,每一次只能向左,右,上,下四个方向移动一格,但是不能进入行坐标和列坐标的数位之和大于k的格子。 例如,当k为18时,机器人能够进入方格(35,37),因为3+5+3+7 = 18。但是,它不能进入方格(35,38),因为3+5+3+8 = 19。请问该机器人能够达到多少个格子?idea:dfs暴力解决codeclas...

2019-04-25 20:19:26 84

原创 矩阵中的路径

题目:请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子。如果一条路径经过了矩阵中的某一个格子,则之后不能再次进入这个格子。 例如 a b c e s f c s a d e e 这样的3 X 4 矩阵中包含一条字符串"bcced"的路径,但是矩阵中不包含"abcb"路径,因为字符串...

2019-04-25 17:55:10 81

原创 滑动窗口的最大值(max pooling的实现)

题目:给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值。例如,如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3,那么一共存在6个滑动窗口,他们的最大值分别为{4,4,6,6,6,5}; 针对数组{2,3,4,2,6,2,5,1}的滑动窗口有以下6个: {[2,3,4],2,6,2,5,1}, {2,[3,4,2],6,2,5,1}, {2,3,[4,2,6],2,5,...

2019-04-25 15:58:08 1887

原创 数据流中的中位数

题目:如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序之后位于中间的数值。如果从数据流中读出偶数个数值,那么中位数就是所有数值排序之后中间两个数的平均值。我们使用Insert()方法读取数据流,使用GetMedian()方法获取当前读取数据的中位数。idea:使用最大堆保存前半数据,最小堆保存后半段数据。保证最大堆size>=最小堆size。...

2019-04-24 21:57:15 170

原创 刷题:二叉搜索树的第k个结点

题目:给定一棵二叉搜索树,请找出其中的第k小的结点。例如, (5,3,7,2,4,6,8) 中,按结点数值大小顺序第三小结点的值为4。idea:使用中序遍历,每遍历一个结点k–,假如k==0则将ans改成该结点。code/*struct TreeNode { int val; struct TreeNode *left; struct TreeNode *...

2019-04-24 20:51:40 109

原创 刷题:序列化二叉树

题目:请实现两个函数,分别用来序列化和反序列化二叉树idea先序遍历,采用带引用的idx记录当前序列下标当结点为空时,用’#'标记,并返回由于char为一个字节,而int为8个字节。当结点非空时用四个单位来保存int数值,分别右移24、16、8、0位然后跟255进行与运算。反序列化时则将这四个单位分别左移然后跟255与运算,最后或起来。code/*struct TreeN...

2019-04-24 19:56:10 164

原创 把二叉树打印成多行

题目:从上到下按层打印二叉树,同一层结点从左至右输出。每一层输出一行。idea:对牛客的这个题目顺序无语,竟然是上一题的简化版。直接层次遍历code/*struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : ...

2019-04-23 12:34:00 124

原创 刷题:按之字型打印二叉树

题目:解法一idea:利用栈的后进先出,每次遍历每一层时简历一个栈来保存下一层的结点。遍历奇数行的时候,让左节点先进栈(这样右节点先出)遍历偶数行的时候,让右节点先进栈codeclass Solution {public: vector<vector<int> > Print(TreeNode* pRoot) { ve...

2019-04-23 12:28:30 236

原创 刷题:对称的二叉树

题目:请实现一个函数,用来判断一颗二叉树是不是对称的。注意,如果一个二叉树同此二叉树的镜像是同样的,定义其为对称的。idea:递归进行。递归函数每次传入两个节点,左边的节点来自左子树,右边的节点来自右子树。两个节点val应该一样,同时左边节点应该与右边节点相反,即左边节点的左子树应该与右边节点的左子树对称,左边节点的右子树应该与右边节点的左子树对称。用一个引用变量保存返回值,如果出现一处...

2019-04-23 11:34:31 125

空空如也

空空如也

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

TA关注的人

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