- 博客(130)
- 收藏
- 关注
原创 Leet Code OJ 22. Generate Parentheses-python
题目:22.Generate ParenthesesMedium5731287Add to ListShareGivennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:[ "((()))", "(()())", "(())()", ...
2020-09-01 20:14:58
359
原创 Leet Code OJ 13. Roman to Integer-python
题目:13.Roman to IntegerEasy24273630Add to ListShareRoman numerals are represented by seven different symbols:I,V,X,L,C,DandM.Symbol ValueI 1V 5X 10L 50C 100D ...
2020-09-01 18:57:25
365
原创 Leet Code OJ 12. Integer to Roman -python
题目:12.Integer to RomanMediumRoman numerals are represented by seven different symbols:I,V,X,L,C,DandM.Symbol ValueI 1V 5X 10L 50C 100D 500M 1...
2020-08-31 22:01:40
280
原创 Leet Code OJ 2. Add Two Numbers [Difficulty: Medium] -python
题目:2.Add Two NumbersMediumYou are given twonon-emptylinked lists representing two non-negative integers. The digits are stored inreverse orderand each of their nodes contain a single digit. Add the two numbers and return it as a linked list.Yo...
2020-08-30 23:02:49
220
原创 Leet Code OJ 127. Word Ladder [Difficulty: Medium]-python
题目:127.Word LadderMediumGiven two words (beginWordandendWord), and a dictionary's word list, find the length of shortest transformation sequence frombeginWordtoendWord, such that:Only one letter can be changed at a time. Each transformed wor...
2020-08-30 16:05:48
216
原创 Leet Code OJ 125. Valid Palindrome [Difficulty: Easy] -python
题目:125.Valid PalindromeEasyGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note:For the purpose of this problem, we define empty string as valid palindrome.Example 1:Input: "A man,..
2020-08-29 21:44:41
194
原创 Leet Code OJ 98. Validate Binary Search Tree [Difficulty: Medium] -python
题目:98.Validate Binary Search TreeMediumGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keysless thanthe node's key. The right subt...
2020-08-29 20:59:16
193
原创 Leet Code OJ 88. Merge Sorted Array [Difficulty: Easy] -python
题目:88.Merge Sorted ArrayEasyGiven two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:The number of elements initialized innums1andnums2aremandnrespectively. You may assume thatnums1has enough sp...
2020-08-29 20:02:41
239
原创 Leet Code OJ 73. Set Matrix Zeroes [Difficulty: Medium] -python
题目73.Set Matrix ZeroesGiven anmxnmatrix. If an element is0, set its entire row and column to0. Do itin-place.Follow up:A straight forward solution using O(mn) space is probably a bad idea. A simple improvement uses O(m+n) space, but stil...
2020-08-29 19:12:55
148
原创 Leet Code OJ 70. Climbing Stairs [Difficulty: Easy] -python
爬楼梯问题:70.Climbing StairsEasyYou are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Example 1:Input: 2Output: 2Explanation: There ar...
2020-08-28 17:21:18
216
原创 Leet Code OJ 65. Valid Number [Difficulty: Hard]-Python
65.Valid NumberHardValidate if a given string can be interpreted asa decimal number.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>true" -90e3 "=>true" 1e"=>false"e3"=>false" 6e-1"=>...
2020-08-28 16:50:23
212
原创 面经杂谈(1)
8/27,今天刷牛客看到的搜狐面经,为了准备面试,我把看到的面经被问到的问题也自己整理回答下,吸取经验:1.说说过拟合首先,在随着训练过程的进行,模型复杂度增加,在训练集上误差逐渐减小,但是在验证集上误差反而越来越大。因为训练出来的网络过度拟合了训练集,对训练集以外的数据不起作用,这就称之为泛化性能不好,泛化性能是训练效果评价中的首要目标。过拟合则是泛化的反面,实际过程中,降低过拟合的方法一般有:(1)正则化L1正则化:目标函数中增加所有权重w参数的绝对值之和, 逼迫更多w为零,也就
2020-08-27 21:30:54
218
原创 Leet Code OJ 57. Insert Interval [Difficulty: Hard] -python
57.Insert Interval[Hard]Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Example 1:Input: intervals = ...
2020-08-27 12:18:55
199
原创 Leet Code OJ 56. Merge Intervals [Difficulty: Medium] -Python
56.Merge Intervals【Medium】Given a collection of intervals, merge all overlapping intervals.Example 1:Input: intervals = [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and [2,6] overlaps, merge them .
2020-08-27 12:08:40
217
原创 平安科技2020校招技术岗部分编程题汇总-分糖果
n个小朋友坐在一排,每个小朋友拥有ai个糖果,现在你要在他们之间转移糖果,使得最后所有小朋友拥有的糖果数都相同,每一次,你只能从一个小朋友身上拿走恰好两个糖果到另一个小朋友上,问最少需要移动多少次可以平分糖果,如果方案不存在输出-1。输入描述:每个输入包含一个测试用例。每个测试用例的第一行包含一个整数n(1 <= n <= 100),接下来的一行包含n个整数ai(1 <= ai <= 100)。输出描述:输出一行表示最少需要移动多少次可以平分苹...
2020-08-26 22:52:41
908
原创 平安科技2020校招技术岗部分编程题汇总-查找字符串最长公共子串
请编码实现一个命令行工具,找出指定的2个字符串的最长公共子串。输入描述:命令行工具接收两个字符串参数。输入字符串的合法字符集为[a-zA-Z0-9],大小写敏感,无需考虑异常输入场景。输出描述:所找到的公共子串;如果存在多个等长的公共子串,则请按字母序排序,依次打印出所有公共子串,每行一个。输入例子1:1234567 12893457输出例子1:345思路:1.建立一个全0矩阵,如果匹配就+1,取对角线上最大值就是最长公共子串了。...
2020-08-26 22:50:54
421
原创 Leet Code OJ 28. Implement strStr() [Difficulty: Easy] -python
28.Implement strStr()EasyImplementstrStr().Return the index of the first occurrence of needle in haystack, or-1if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2Example 2:Input: haystack = "a...
2020-08-26 22:36:34
197
原创 平安科技2020校招技术岗部分编程题汇总-字符串异构同质判定
题目:请编码实现一个命令行工具,判定两个指定的字符串是否异构同质;异构同质的定义为:一个字符串的字符重新排列后,能变成另一个字符串。输入描述:以空格字符分隔的两个字符串;输入字符串的合法字符集为[a-zA-Z0-9 ],大小写敏感,无需考虑异常输入场景。输出描述:如果判定两个字符串异构同质,则输出true,否则输出false。输入例子1:abc acb输出例子1:true解法,就是分别将两字符串排序再判断是否相等。或者直接计数每个字符的...
2020-08-26 12:51:19
527
原创 Leet Code OJ 21. Merge Two Sorted Lists [Difficulty: Easy] -python
21.Merge Two Sorted Lists[Easy]Merge two sorted linked lists and return it as a newsortedlist. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1->1->2-&...
2020-08-26 00:12:59
188
原创 Leet Code OJ 20. Valid Parentheses [Difficulty: Easy] -python
20.Valid Parentheses[Easy]Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of brackets. Open brackets m...
2020-08-24 22:29:02
199
原创 Leet Code OJ 15. 3Sum [Difficulty: Medium]-python
题目:一开始是用暴力求解,结果TL,超时。代码如下:#15#先对数据排序,如果第一个数就大于0则不可能和为0class Solution: def threeSum(self, nums): x=[] y=[] y1=[] nums.sort() for i in range(0,len(nums)-2): if nums[0
2020-08-23 23:38:47
154
原创 Leet Code OJ 8. String to Integer (atoi) [Difficulty: Medium] -python
题目:https://leetcode.com/problems/string-to-integer-atoi/8.String to Integer (atoi)Medium16849704Add to ListShareImplementatoiwhichconverts a string to an integer.The function first discards as many whitespace characters as necessary until the...
2020-08-22 23:51:32
225
原创 Leet Code OJ 1. Two Sum [Difficulty: Easy]-Python
题目:1.Two SumGiven an array of integers, returnindicesof the two numbers such that they add up to a specific target.You may assume that each input would haveexactlyone solution, and you may not use thesameelement twice.Example:Given nums =...
2020-08-07 22:13:52
193
原创 Leet Code OJ 刷题顺序参考
出现频度为5:1.Leet Code OJ 1. Two Sum [Difficulty: Easy]2.Leet Code OJ 8. String to Integer (atoi) [Difficulty: Easy]3.Leet Code OJ 15. 3Sum [Difficulty: Medium]4.Leet Code OJ 20. Valid Parentheses [Difficulty: Easy]5.Leet Code OJ 21. Merge Two S...
2020-08-07 22:00:32
513
原创 使用 pip install torchvision 报错
使用 pip install torchvision 报错解决办法:换命令:conda install torchvision或者conda install torchvision -c pytorch亲测第一个成功,第二个可能不行
2020-06-30 10:20:54
2415
2
原创 windows情况下关于”python Jupyter不能导入外部,但是终端可以import“的问题的解决办法
感谢博客提供的方案,亲测有效。https://blog.youkuaiyun.com/qq_42182367/article/details/82594994问题解决!
2020-03-03 21:40:39
493
原创 apt-get安装问题:请尝试不指明软件包的名字来运行“apt-get -f install”
正在读取软件包列表... 完成正在分析软件包的依赖关系树... 完成您可能需要运行“apt-get -f install”来纠正下列错误:下列的软件包有不能满足的依赖关系:cdparanoia: 依赖: libcdparanoia0 (= 3a9.8-11) 但是,它将不会被安装gpdf: 依赖: libgnomeprint2.2-0 (>= 2.4.2) 但是,它将不会被安装依...
2019-11-18 16:21:10
784
原创 解决Ubuntu中Chrome插件安装时程序包无效:"CRX_HEADER_INVALID"
打开chorme的扩展程序(设置——>更多工具——>扩展程序)chrome://extensions选择开发者模式拖拽.crx至Chrome的扩展程序列表安装失败报错为:程序包无效:"CRX_HEADER_INVALID"成功安装的操作如下:下载的后缀名改为zip:提取zip到一个文件夹中选择那个文件夹然后成功了:...
2019-08-26 16:30:51
1325
1
原创 安装遇到问题 ERROR: Cannot uninstall 'Werkzeug'. It is a distutils installed project and ……
安装遇到问题:ERROR: Cannot uninstall 'Werkzeug'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.将下载命令...
2019-08-25 15:34:40
5557
原创 Pytorch快速搭建神经网络
(一)init和forward每一个torch模块当中都有__init__()和forward()__init__()里面包含搭建神经网络那些层所需要的信息;forward()包含神经网络前向传递的内容;比如init里面的那些层的组合就是由forward来完成;(二)要继承父类的__init__()(三)搭建层其中对于hidden:n_features是输入;n_h...
2019-08-01 13:55:45
429
原创 virtualbox怎么实现双向复制粘贴,安装增强功能时点击没反应(解决办法)
详情见:(1)安装增强功能时点击没反应(解决办法):http://taotaoit.com/article/details/139.html(2)virtualbox怎么实现双向复制粘贴https://blog.youkuaiyun.com/lyc_daniel/article/details/12613675...
2019-07-29 15:41:35
8137
原创 The Primes as a Result of the Longest Consecutive Sum I
好久没写codewars,哎,颓废了好多天。今天一写一题就是一天最后还是timeout,尴尬至极,但是至少输出答案都能对,需要优化代码。题目:https://www.codewars.com/kata/the-primes-as-a-result-of-the-longest-consecutive-sum-i/train/pythonThe Primes as a Result...
2019-07-22 19:52:35
218
原创 U盘在Ubuntu中不可复制文件、移动文件-问题解决
今天找师兄拷贝实验数据集;结果师兄一插入自己Ubuntu系统的电脑,复制文件到我U盘上复制不进去……前脚我还去Windows系统上打印了,后脚就不行了,咋回事。在网上百度了一下,试了几种方法终于行了。感谢博客:https://blog.youkuaiyun.com/ITBigGod/article/details/79914534按照这种方法多试几次就可以恢复了。...
2019-03-03 14:36:26
7425
原创 电视剧《知否知否,应是绿肥红瘦》——剧评词云制作
前几天看了一下csdn微信公众号发的关于知否剧评的词云制作觉得很有趣,因此也模仿了一下十分有趣,可是还有些细节要注意。第一步代码如下:# -*-coding:utf-8-*-#导入相关模块import requestsfrom lxml import etreeimport jiebaimport time#载入浏览器请求头,避免被检测header = { "U...
2019-02-14 22:00:10
774
原创 入坑codewars第21天-Numbers that are a power of their sum of digits
新年第一道题,已经几个月没写了,哎,毕业设计整不出The number 81 has a special property, a certain power of the sum of its digits is equal to 81 (nine squared). Eighty one (81), is the first number in having this property (n...
2019-02-09 23:09:44
425
原创 入坑codewars第20天- Rot13
题目:ROT13 is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is an example of the Caesar cipher.Create a function that takes a ...
2018-12-25 11:31:03
610
原创 入坑codewars第19天-Calculating with Functions
题目:This time we want to write calculations using functions and get the results. Let's have a look at some examples:JavaScript:seven(times(five())); // must return 35four(plus(nine())); // must...
2018-12-21 11:09:28
978
原创 入坑codewars第18天-Alphabet wars - nuclear strike
题目:Alphabet wars - nuclear strikeIntroductionThere is a war and nobody knows - the alphabet war!The letters hide in their nuclear shelters. The nuclear strikes hit the battlefield and killed a lo...
2018-12-20 17:17:31
320
原创 入坑codewars第17天-Directions Reduction
题目:Once upon a time, on a way through the old wild west,…… a man was given directions to go from one point to another. The directions were "NORTH", "SOUTH", "WEST", "EAST". Clearly "NORTH" and "SO.
2018-12-16 14:04:21
798
2
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人