
python3
soufal
going
展开
-
LeetCode 刷题记录 141. 环形链表
基于快慢指针的思想,定义两个指针,快指针比慢指针快一步,即慢指针一次迭代前进一步,快指针一次迭代前进两步,如果链表存在环,则经过若干次迭代,快指针总会在某个时刻和慢指针相遇。指针再次到达,则链表中存在环。为了表示给定链表中的环,评测系统内部使用整数。不作为参数进行传递。仅仅是为了标识链表的实际情况。来表示链表尾连接到链表中的位置(索引从。如果链表中有某个节点,可以通过连续跟踪。如果链表中存在环 ,则返回。,判断链表中是否有环。给你一个链表的头节点。原创 2023-03-20 16:14:29 · 178 阅读 · 0 评论 -
LeetCode 刷题记录707. 设计链表
设计链表原创 2023-01-17 16:04:25 · 142 阅读 · 0 评论 -
LeetCode 刷题记录14. 最长公共前缀
LeetCode刷题记录14原创 2022-11-19 16:52:48 · 236 阅读 · 0 评论 -
LeetCode刷题记录1720.解码异或后的数组
这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入欢迎使用Markdown编辑器你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Mar原创 2022-11-19 16:21:38 · 381 阅读 · 0 评论 -
LeetCode 刷题记录26. 删除有序数组中的重复项
题目描述:给你一个有序数组 nums ,请你 原地 删除重复出现的元素,使每个元素 只出现一次 ,返回删除后数组的新长度。不要使用额外的数组空间,你必须在 原地 修改输入数组 并在使用 O(1) 额外空间的条件下完成。说明:为什么返回数值是整数,但输出的答案是数组呢?请注意,输入数组是以「引用」方式传递的,这意味着在函数里修改输入数组对于调用者是可见的。你可以想象内部操作如下:// nums 是以“引用”方式传递的。也就是说,不对实参做任何拷贝int len = removeDuplicat转载 2021-05-28 17:38:29 · 105 阅读 · 0 评论 -
DataWhale计算机视觉实践(目标检测)Task04
DataWhale计算机视觉实践(目标检测)Task04文章目录DataWhale计算机视觉实践(目标检测)Task04目标检测一、训练与测试模型训练后处理目标框信息解码`NMS`非极大值抑制单图预测推理VOC测试集评测`map`指标Tiny-Detection VOC测试集评测文中图片和部分内容、代码转自:动手学CV-Pytorch目标检测一、训练与测试模型训练目标检测网络的训练大致流程为:设置各种超参数定义数据加载模块dataloader定义网络model定义损失函数lo原创 2020-12-27 21:42:47 · 342 阅读 · 0 评论 -
DataWhale计算机视觉实践(目标检测)Task03
DataWhale计算机视觉实践(目标检测)Task02文章目录DataWhale计算机视觉实践(目标检测)Task02目标检测一、损失函数1. Matching strategy(匹配策略)2. 损失函数:3. Hard negative mining总结文中图片和部分内容、代码转自:动手学CV-Pytorch目标检测一、损失函数1. Matching strategy(匹配策略)在上一部分内容中,分配了许多prior bboxes,要想让他们去预测类别和目标框信息,那就需要先知道原创 2020-12-22 22:02:07 · 240 阅读 · 1 评论 -
DataWhale计算机视觉实践(目标检测)Task02
DataWhale计算机视觉实践(目标检测)Task02文章目录DataWhale计算机视觉实践(目标检测)Task02目标检测一. 锚框/先验框1. 先验框设置不同尺度的先验框先验框与特征图的对应先验框类别信息的确定2. 先验框的生成二. 模型结构1. VGG16作为backbone2. 先验框设置3. 分类头和回归头边界框的解编码分类头与回归头预测小结:文中图片和部分内容、代码转自:动手学CV-Pytorch目标检测一. 锚框/先验框1. 先验框锚点(anchor)==先验框(p原创 2020-12-19 22:17:37 · 290 阅读 · 1 评论 -
剑指offer---旋转数组的最小数字
剑指offer—旋转数组的最小数字题目描述:把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。 该题考查的是如何使用时间复杂度小于O(n) 的方法来找到这个最小值,...原创 2018-09-07 23:48:25 · 150 阅读 · 0 评论 -
2018迅雷校园招聘客户端在线笔试B卷---输入一个有符号整数,输出该整数的反转值。
2018迅雷校园招聘客户端在线笔试B卷—输入一个有符号整数,输出该整数的反转值。题目描述: 输入一个有符号整数,输出该整数的反转值。 代码如下:num = list(input())if num[0] != '-': num = num[::-1]else: num = num[::-1] temp = num.pop() num.insert(0,...原创 2018-09-07 21:31:30 · 1109 阅读 · 2 评论 -
剑指offer---连续子数组的最大和
剑指offer—连续子数组的最大和题目描述:给定一个输入数组,输出该数组的中所以子数组的和的最大值。时间复杂度为O(n)。思路: 一、由于数组中有正有负,因此我们可以顺序遍历一般数组,依次累加每一个数字。如果累加到某一个数字i时的结果比他本身还小时,就说明前i-1个数字构成的子序列和还没有这一个数字i大。故将之前得到的和抛弃,选择当前数字i作为新的最大和,继续循环。这样值循环一次得到的结...原创 2018-09-04 16:58:26 · 157 阅读 · 0 评论 -
Codewars第十三天–Simplifying multilinear polynomials
Codewars第十三天–Simplifying multilinear polynomials题目描述: 当我们上中学时被要求简化数学表达式,如“3x-yx + 2xy-x”(或通常更大),这很容易(“2x + xy”)。但告诉你的电脑,我们会看到!写一个函数:简化(聚) 在输入中取一个字符串,表示整数系数中的多线性非常数多项式(如“3x-zx + 2xy-x”),并返回另一个字...原创 2018-08-29 11:16:38 · 519 阅读 · 0 评论 -
Codewars第八天--Valid Parentheses(带有字母的单个括号匹配)
Codewars第八天–Valid Parentheses(带有字母的单个括号匹配)题目描述: 该题只需要匹配一种括号,但是其中会有字母干扰。 比如测试用例为:Test.assert_equals(valid_parentheses(" ("),False)Test.assert_equals(valid_parentheses(")test"),False)Test.asser...原创 2018-08-21 19:52:40 · 430 阅读 · 0 评论 -
剑指offer---两个栈实现队列
剑指offer—两个栈实现队列题目描述: 用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。使用一个栈stack1 来存储队列插入的值,使用另一个栈stack2 来进行队列删除。因为队列是先进先出,而栈是后进先出的,因此插入将先把值插入到stack1 中,删除时需要改变值的顺序,将stack1 中栈顶的值一次pop() 到stack2 中,此时stack...原创 2018-09-07 10:38:11 · 171 阅读 · 0 评论 -
Codewars第八天–Valid Braces
Codewars第八天–Valid Braces题目描述: 这道题是常见的不同括号之间的匹配问题。给定一个括号序列,给出他是否匹配的结果,匹配则返回True ,否则返回False 。 例如:"(){}[]" => True"([{}])" => True&原创 2018-08-21 17:42:31 · 292 阅读 · 0 评论 -
Codewars第十四天–Numbers that are a power of their sum of digits
Codewars第十四天–Numbers that are a power of their sum of digits题目描述: 数字81有一个特殊的属性,其数字之和的某个幂等于81(九的平方)。 八十一(81),是拥有这个属性的第一个数字(不考虑一位数字)。 下一个是512.让我们看两个案例的细节 8+1=98+1=98 + 1 = 9且 92=8192=819^2 = 81 51...原创 2018-09-02 16:12:28 · 302 阅读 · 0 评论 -
(Python实现)剑指offer---重建二叉树
(Python实现)剑指offer—重建二叉树题目描述:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。 思路:可以根据前序遍历中的第一个节点为根节点的值,去扫描中序遍历的序列,可以确定根节点在中序遍历...原创 2018-09-09 23:06:17 · 521 阅读 · 0 评论 -
(Python实现)剑指offer---斐波那契数列
(Python实现)剑指offer—斐波那契数列题目描述:大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0)。n<=39 这个题目也不难,第一反应应该是使用递归来编写代码,我的第一反应也是,但是看过书后发现,如果使用递归的话,当n 很大时,递归计算的时间复杂度时以n 的指数方式增长的。复杂度过高。 如果使用循环的话,其时间复杂度恒为O...原创 2018-09-09 23:23:24 · 339 阅读 · 0 评论 -
剑指offer---从头到尾打印列表
剑指offer—从头到尾打印列表 题目描述: 输入一个链表,按链表值从尾到头的顺序返回一个ArrayList。解题思路: 这道题不难,可以使用栈来实现,将原数组的值依次存入一个新的栈中。然后再弹出。代码如下:# -*- coding:utf-8 -*-# class ListNode:# def __init__(self, x):# self.val ...原创 2018-09-06 23:47:37 · 243 阅读 · 0 评论 -
Python学习记录(一)-----数据类型
重新开始复习和巩固Python的知识,以思维导图的形式来记录,感觉这种方式挺好的,适合自己学习和总结。原创 2018-10-23 10:23:13 · 196 阅读 · 0 评论 -
Python学习记录(二)----高级特性
一个使用生成器生成斐波拉契数列的例子#利用生成器生成斐波那契数列#普通函数生成斐波拉契数列def Fibonacci(num): n0, n1 = 1, 1 for i in range(num): print(n0, end=" ") n0, n1 = n1, n0+n1 print('\n')Fibonacci(6)#生成器...原创 2018-10-23 10:25:46 · 188 阅读 · 0 评论 -
Codewars第二天--Disemvowel Trolls
Codewars第二天–Disemvowel Trolls继续刷题,题目描述为: Trolls are attacking your comment section! A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing ...原创 2018-07-20 14:54:03 · 614 阅读 · 0 评论 -
Codewars第八天--Good vs Evil
Codewars第八天–Good vs Evil题目描述:霍比特人:1男子:2精灵:3矮人:3老鹰队:4巫师:10在邪恶的一面,我们有:兽人:1男子:2Wargs:2哥布林:2Uruk Hai:3巨魔:5巫师:10输入:该函数将给出两个参数。每个参数都是由单个空格分隔的字符串。每个字符串将包含善恶方面的每个种族的数量。第一个参数将按以下顺序包含go...原创 2018-08-21 17:14:15 · 287 阅读 · 0 评论 -
Codewars第八天--Roman Numerals Encoder
Codewars第八天–Roman Numerals Encoder题目描述: 给定一个数字n ,返回该数字对应的罗马数字。 在罗马技术中 1990 : 1000=M, 900=CM, 90=XC; 结果为: MCMXC. 2008 可以被写作: 2000=MM, 8=VIII; 结果为: MMVIII. 1666 被描述为: MDCLXVI。但是相同的罗马字不能够超过三个,比如9 不能够...原创 2018-08-21 16:13:31 · 279 阅读 · 0 评论 -
Codewars第三天--Largest 5 digit number in a series
Codewars第三天–Largest 5 digit number in a series In the following 6 digit number:28391091 is the greatest sequence of 2 consecutive digits.In the following 10 digit number:123456789067890...原创 2018-07-22 18:37:59 · 367 阅读 · 0 评论 -
Codewars第三天--Unique In Order
Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each other and preserving the original order of e...原创 2018-07-22 18:06:14 · 382 阅读 · 0 评论 -
Codewars第四天--Find the stray number
Codewars第四天–Find the stray number题目描述: You are given an odd-length array of integers, in which all of them are the same, except for one single number. Complete the method which accepts such an a...原创 2018-07-22 14:50:56 · 271 阅读 · 0 评论 -
Codewars第三天--The museum of incredible dull things
Codewars第三天–The museum of incredible dull things题目描述: The museum of incredible dull things wants to get rid of some exhibitions. Miriam, the interior architect, comes up with a plan to remove the m...原创 2018-07-21 13:03:42 · 573 阅读 · 0 评论 -
Codewars第三天--Binary Addition
Codewars第三天–Binary Addition题目描述: Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before, or after the addition. The binary number re...原创 2018-07-21 11:57:31 · 461 阅读 · 0 评论 -
Codewars第二天--Complementary DNA
Codewars第二天–Complementary DNA开始在Codewars刷Python3题,发现基本知识都忘完了,边刷边复习边记录。 8kyu>>7kyu Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" f...原创 2018-07-20 10:23:38 · 501 阅读 · 0 评论 -
Codewars第五天--Sort the odd
Codewars第五天–Sort the odd题目描述: You have an array of numbers. Your task is to sort ascending odd numbers but even numbers must be on their places. Zero isn't an odd number and you don't need to mov...原创 2018-07-24 21:21:48 · 342 阅读 · 0 评论 -
Codewars第五天--Stop gninnipS My sdroW!
Codewars第五天–Stop gninnipS My sdroW!题目描述: Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (Just like the na...原创 2018-07-24 20:54:02 · 805 阅读 · 0 评论 -
Codewars第四天--Sum of Digits / Digital Root
Codewars第四天–Sum of Digits / Digital Root题目描述: In this kata, you must create a digital root function. A digital root is the recursive sum of all the digits in a number. Given n, take the sum of the...原创 2018-07-23 21:03:17 · 650 阅读 · 0 评论 -
Codewars第三天--Breaking chocolate problem
Your task is to split the chocolate bar of given dimension n x m into small squares. Each square is of size 1x1 and unbreakable. Implement a function that will return minimum number of breaks needed....原创 2018-07-22 18:53:42 · 496 阅读 · 0 评论 -
Codewars第三天--Create Phone Number
Codewars第三天–Create Phone NumberWrite a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number.Example: create_phone_...原创 2018-07-22 19:43:24 · 588 阅读 · 1 评论 -
Codewars第六天--Where my anagrams at?
Codewars第六天–Where my anagrams at?题目描述: What is an anagram? Well, two words are anagrams of each other if they both contain the same letters. For example:'abba' & 'baab' == true'abba' & ...原创 2018-08-16 15:36:22 · 305 阅读 · 0 评论 -
Codewars第十一天–PermutationsPrimes in numbers
Codewars第十一天–PermutationsPrimes in numbers题目描述: 给定一个数n ,返回他的素因子。 例如:Example: n = 86240 should return "(2**5)(5)(7**2)(11)"参考的比较好的代码如下:def primeFactors(n): i, j, p = 2, 0, [] while ...原创 2018-08-24 15:23:34 · 376 阅读 · 0 评论 -
Codewars第十一天–PermutationsNumber of trailing zeros of N!
Codewars第十一天–PermutationsNumber of trailing zeros of N!题目描述: 给定一个数n ,返回n 的阶乘中末尾0 的个数。比如:zeros(6) = 1# 6! = 1 * 2 * 3 * 4 * 5 * 6 = 720 --> 1 trailing zerozeros(12) = 2# 12! = 479001600 --&...原创 2018-08-24 11:26:01 · 215 阅读 · 0 评论 -
Codewars第十天–Permutations
Codewars第十天–Permutations题目描述: 这是一道常见的全排列题目。需要返回输入字符串的所有排列并删除重复项(如果存在)。 例如:permutations('a'); # ['a']permutations('ab'); # ['ab', 'ba']permutations('aabb'); # ['aabb', 'abab', 'abba', 'baab',...原创 2018-08-23 17:10:48 · 464 阅读 · 0 评论 -
LeetCode第一题-----三数之和
题目要求: 给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组。注意:答案中不可以包含重复的三元组。例如, 给定数组 nums = [-1, 0, 1, 2, -1, -4],满足要求的三元组集合为: [-1, 0, 1], [-1, -1, 2]]cla...原创 2018-08-30 16:48:21 · 184 阅读 · 0 评论