<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[CSerwangjun的博客]]></title><description><![CDATA[]]></description><link>https://blog.youkuaiyun.com/CSerwangjun</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; CSerwangjun]]></copyright><item><title><![CDATA[leetcode 32. Longest Valid Parentheses Python3 解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/110958659</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/110958659</guid><author>CSerwangjun</author><pubDate>Thu, 10 Dec 2020 20:05:53 +0800</pubDate><description><![CDATA[一.问题描述

Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.



Example 1:


Input: s = "(()"
Output: 2
Explanation: The longest valid parentheses substring is "()".


Example...]]></description><category></category></item><item><title><![CDATA[leetcode 30. Substring with Concatenation of All Words Python3]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/109134153</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/109134153</guid><author>CSerwangjun</author><pubDate>Sat, 17 Oct 2020 17:02:08 +0800</pubDate><description><![CDATA[一.问题描述

You are given a stringsand an array of stringswordsofthe same length. Returnall starting indices of substring(s) insthat is a concatenation of each word inwordsexactly once,in any order,andwithout any intervening characters.

You can r...]]></description><category></category></item><item><title><![CDATA[leetcode 25. Reverse Nodes in k-Group Python3 递归+迭代]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/109124487</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/109124487</guid><author>CSerwangjun</author><pubDate>Fri, 16 Oct 2020 21:03:21 +0800</pubDate><description><![CDATA[一.问题描述

Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.

kis a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple ofkthen left-out nodes...]]></description><category></category></item><item><title><![CDATA[leetcode 23. Merge k Sorted Lists Python3 多解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/109107936</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/109107936</guid><author>CSerwangjun</author><pubDate>Fri, 16 Oct 2020 00:43:46 +0800</pubDate><description><![CDATA[一.问题描述

You are given an array ofklinked-listslists, each linked-list is sorted in ascending order.

Merge all the linked-lists into one sorted linked-list and return it.



Example 1:


Input: lists = [[1,4,5],[1,3,4],[2,6]]
Output: [1,1,2,3,4,4,5,6]
...]]></description><category></category></item><item><title><![CDATA[Leetcode 10. Regular Expression Matching Python3 递归与动态规划]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/109088477</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/109088477</guid><author>CSerwangjun</author><pubDate>Thu, 15 Oct 2020 00:46:46 +0800</pubDate><description><![CDATA[一.问题描述

Given an input string (s) and a pattern (p), implement regular expression matching with support for'.'and'*'where:

'.'Matches any single character.​​​​
	'*'Matches zero or more of the preceding element.
The matching should cover theentire...]]></description><category></category></item><item><title><![CDATA[ECCV20| Mining Cross-Image Semantics for Weakly Supervised Semantic Segmentation 解读]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/108920997</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/108920997</guid><author>CSerwangjun</author><pubDate>Sun, 04 Oct 2020 21:40:19 +0800</pubDate><description><![CDATA[论文地址:Mining Cross-Image Semantics for Weakly Supervised Semantic Segmentation
概述：
本篇论文是由来自苏黎世联邦理工学院和上海交通大学的Guolei Sun等人提出，被ECCV 2020(oral)接收。其旨在通过挖掘跨图像的语义信息来促进弱监督语义分割(WSSS)任务。具体来说，他们提出了一个 co-attention (共同注意力) 机制和 contrastive (对比共同注意力) 机制来帮助分类器更好的学习物体的模式 (p]]></description><category></category></item><item><title><![CDATA[UserWarning: This overload of nonzero is deprecated: nonzero(Tensor input, Tensor out) 解决]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/108696236</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/108696236</guid><author>CSerwangjun</author><pubDate>Sun, 20 Sep 2020 18:08:30 +0800</pubDate><description><![CDATA[问题:


../torch/csrc/utils/python_arg_parser.cpp:738: UserWarning: This overload of nonzero is deprecated:
        nonzero(Tensor input, Tensor out)
Consider using one of the following signatures instead:
        nonzero(Tensor input, bool as_tuple)

解决：

.]]></description><category></category></item><item><title><![CDATA[剑指offer JZ27 字符串的排列 Python 多解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/107436799</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/107436799</guid><author>CSerwangjun</author><pubDate>Sat, 18 Jul 2020 23:48:40 +0800</pubDate><description><![CDATA[一.题目描述

输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。

输入描述:


输入一个字符串,长度不超过9(可能有字符重复),字符只包括大小写字母。


二.解题思路

1.递归+dfs

深度优先搜索。

要注意本题的输出要求字典序输出。

如何字典序的获得一个字符串的全排列？

我们可以这样想，

假设字符串s长为n，我们已知基于s的2～n位的子字符串的全排列，将第一个字.]]></description><category></category></item><item><title><![CDATA[剑指offer JZ52 正则表达式匹配 Python 多解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/107402290</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/107402290</guid><author>CSerwangjun</author><pubDate>Fri, 17 Jul 2020 10:43:49 +0800</pubDate><description><![CDATA[一.题目描述

请实现一个函数用来匹配包括'.'和'*'的正则表达式。模式中的字符'.'表示任意一个字符，而'*'表示它前面的字符可以出现任意次（包含0次）。 在本题中，匹配是指字符串的所有字符匹配整个模式。例如，字符串"aaa"与模式"a.a"和"ab*ac*a"匹配，但是与"aa.a"和"ab*a"均不匹配

二.解题思路

&lt;1&gt;递归

首先分析一下匹配可能的集中情况。

1.s和pattern都为空:返回True

2.s不为空pattern为空:返回False

3.s为空，patte]]></description><category></category></item><item><title><![CDATA[剑指offer JZ43 左旋转字符串 Python 多解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/107380416</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/107380416</guid><author>CSerwangjun</author><pubDate>Thu, 16 Jul 2020 12:37:15 +0800</pubDate><description><![CDATA[一.题目描述

汇编语言中有一种移位指令叫做循环左移（ROL），现在有个简单的任务，就是用字符串模拟这个指令的运算结果。对于一个给定的字符序列S，请你把其循环左移K位后的序列输出。例如，字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果，即“XYZdefabc”。是不是很简单？OK，搞定它！

二.解题思路

1.空间复杂度O(N)，时间复杂度O(N)

a.将字符串n~末尾和0～n拼接起来返回，这用python很容易实现。

b.将两个相同的字符串s拼接，然后返回s[n～len(s)+n)]]]></description><category></category></item><item><title><![CDATA[剑指offer JZ53 表示数值的字符串 Python 多解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/107367555</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/107367555</guid><author>CSerwangjun</author><pubDate>Wed, 15 Jul 2020 18:36:42 +0800</pubDate><description><![CDATA[一.题目描述

请实现一个函数用来判断字符串是否表示数值（包括整数和小数）。例如，字符串"+100","5e2","-123","3.1416"和"-1E-16"都表示数值。 但是"12e","1a3.14","1.2.3","+-5"和"12e+4.3"都不是。

二.解题思路

首先分析一下不是数字的情况：

1.出现的字符不是合理的数字或者符号位、e/E等，如'a'.

2.小数点,e出现超过1次。

3.小数点,e,符号出现在字符串末尾

4.符号位不是出现在最高位，如第一位或者e的后面。

5.e]]></description><category></category></item><item><title><![CDATA[剑指offer JZ54 字符流中第一个不重复的字符 Python 多解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/107331917</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/107331917</guid><author>CSerwangjun</author><pubDate>Tue, 14 Jul 2020 10:45:07 +0800</pubDate><description><![CDATA[一.问题描述

请实现一个函数用来找出字符流中第一个只出现一次的字符。例如，当从字符流中只读出前两个字符"go"时，第一个只出现一次的字符是"g"。当从该字符流中读出前六个字符“google"时，第一个只出现一次的字符是"l"。
输出描述:
如果当前字符流没有存在出现一次的字符，返回#字符。

二.解题思路

这道题如果是要O(n)解法，就十分简单，我们在这就不探讨了，在这主要介绍两个O(1)时间复杂度的解法。

1.

时间复杂度: O(1),空间复杂度: O(n)

用一个集合来保存所有曾经出现过的字符]]></description><category></category></item><item><title><![CDATA[剑指offer JZ45 扑克牌顺子 Python 解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/107313537</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/107313537</guid><author>CSerwangjun</author><pubDate>Mon, 13 Jul 2020 11:30:53 +0800</pubDate><description><![CDATA[一.题目描述

LL今天心情特别好,因为他去买了一副扑克牌,发现里面居然有2个大王,2个小王(一副牌原本是54张^_^)...他随机从中抽出了5张牌,想测测自己的手气,看看能不能抽到顺子,如果抽到的话,他决定去买体育彩票,嘿嘿！！“红心A,黑桃3,小王,大王,方片5”,“Oh My God!”不是顺子.....LL不高兴了,他想了想,决定大\小 王可以看成任何数字,并且A看作1,J为11,Q为12,K为13。上面的5张牌就可以变成“1,2,3,4,5”(大小王分别看作2和4),“So Lucky!”。LL决]]></description><category></category></item><item><title><![CDATA[剑指offer JZ02 替换空格 Python 解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/107297044</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/107297044</guid><author>CSerwangjun</author><pubDate>Sun, 12 Jul 2020 11:43:23 +0800</pubDate><description><![CDATA[一.题目描述

请实现一个函数，将一个字符串中的每个空格替换成“%20”。例如，当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。

二.解题思路

这道题其实主要是考察inplace的修改，即在原变量上，不申请新的对象，进行修改。

C/C++,Java传的参数都是可变长的字符串变量。比如char指针和StringBuffer.

但是对于python来说就没有，不过按照思路来说还是讲一讲。

1.新开一个空字符串rst，一次遍历原字符串，如果不是空格，则将原字]]></description><category></category></item><item><title><![CDATA[剑指offer JZ31 整数中1出现的次数 Python 解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/107246167</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/107246167</guid><author>CSerwangjun</author><pubDate>Fri, 10 Jul 2020 12:42:30 +0800</pubDate><description><![CDATA[一.题目描述

求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数？为此他特别数了一下1~13中包含1的数字有1、10、11、12、13因此共出现6次,但是对于后面问题他就没辙了。ACMer希望你们帮帮他,并把问题更加普遍化,可以很快的求出任意非负整数区间中1出现的次数（从1 到 n 中1出现的次数）。

二.解题思路

1.暴力法：从1~n迭代，计算每个数字中1的数量然后累加。复杂度应该是 O(NlgN)

2.归纳法：

2.1

简单来说，分别归纳个位，十位和百位上1的出现次]]></description><category></category></item><item><title><![CDATA[剑指offer JZ06 旋转数组的最小数字 Python解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/107235685</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/107235685</guid><author>CSerwangjun</author><pubDate>Thu, 09 Jul 2020 19:32:03 +0800</pubDate><description><![CDATA[一.题目描述

把一个数组最开始的若干个元素搬到数组的末尾，我们称之为数组的旋转。
输入一个非递减排序的数组的一个旋转，输出旋转数组的最小元素。
例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转，该数组的最小值为1。
NOTE：给出的所有元素都大于0，若数组大小为0，请返回0。

二.解题思路

1.一次扫描：O(N),从头开始扫描数组，发现当前元素比前一元素小，说明是最小元素。注意边界处理。

2.二分法：

具体来说三种情况：

1.array[mid]&lt;array[high]:说]]></description><category></category></item><item><title><![CDATA[剑指offer JZ01 二维数组中的查找 Python 多解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/107215350</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/107215350</guid><author>CSerwangjun</author><pubDate>Wed, 08 Jul 2020 21:27:32 +0800</pubDate><description><![CDATA[一.题目描述

在一个二维数组中（每个一维数组的长度相同），每一行都按照从左到右递增的顺序排序，每一列都按照从上到下递增的顺序排序。请完成一个函数，输入这样的一个二维数组和一个整数，判断数组中是否含有该整数。

二.解题思路

要注意数组的有序信息

1.暴力穷举：O(M*N)

2.单折半:O(M*logN)：迭代每一行，每一行是有序的，二分搜索

3.左下/右上(M+N)：右上是该行和该列（该元素所在列以上的元素）所有元素里最大，若target比该元素大，则只能向下移动一行，小的话则遍历当前行。每次可以]]></description><category></category></item><item><title><![CDATA[leetcode 22. Generate Parentheses 递归+迭代 python3]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/105150163</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/105150163</guid><author>CSerwangjun</author><pubDate>Fri, 27 Mar 2020 21:39:39 +0800</pubDate><description><![CDATA[一.问题描述

Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.

For example, givenn= 3, a solution set is:


[
  "((()))",
  "(()())",
  "(())()",
  ...]]></description><category></category></item><item><title><![CDATA[leetcode 46. Permutations 迭代+递归 python3]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/105101834</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/105101834</guid><author>CSerwangjun</author><pubDate>Wed, 25 Mar 2020 19:00:11 +0800</pubDate><description><![CDATA[一.问题描述

Given a collection ofdistinctintegers, return all possible permutations.

Example:


Input: [1,2,3]
Output:
[
  [1,2,3],
  [1,3,2],
  [2,1,3],
  [2,3,1],
  [3,1,2],
  [3,2,1]
]

二.解题思路

主要是有...]]></description><category></category></item><item><title><![CDATA[What‘s the Point: Semantic Segmentation with Point Supervision 翻译与简单注解]]></title><link>https://blog.youkuaiyun.com/CSerwangjun/article/details/104111807</link><guid>https://blog.youkuaiyun.com/CSerwangjun/article/details/104111807</guid><author>CSerwangjun</author><pubDate>Sat, 01 Feb 2020 08:30:11 +0800</pubDate><description><![CDATA[声明：本篇为原论文的翻译，限于博主的知识，可能有翻译或理解不对的地方，若发现请在评论区留言更改。省略related work和致谢部分。所有的公式，图均来自原文。

原文：What’s the Point: Semantic Segmentation with Point Supervision

Abstract:

语义分割任务在测试准确率和训练注解成本之间获取平衡。细致的每像素注解能训练准确...]]></description><category></category></item></channel></rss>