自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

yuweiming70的博客

清华材料大三 cs入门者

  • 博客(35)
  • 收藏
  • 关注

原创 Leetcode 806 Number of Lines To Write String 字符串的行数

题目描述:We are to write the letters of a given string S, from left to right into lines. Each line has maximum width 100 units, and if writing a letter would cause the width of the line to exceed 100 unit...

2018-03-25 11:05:11 1172

原创 Leetcode 807 Max Increase to Keep City Skyline 不变天际线

题目描述:In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of any number of buildings, by any amount (the amount...

2018-03-25 11:05:09 1208 1

原创 Leetcode 804 Unique Morse Code Words 莫尔斯电码重复问题

题目描述:International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ".-", "b" maps to "-...", "c" maps to "-.-.", and so o

2018-03-25 11:05:07 2196

原创 Leetcode 108 Convert Sorted Array to Binary Search Tree 将一个有序数组变成BST

题目描述:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of ...

2018-03-24 20:40:14 186

原创 Leetcode 107 Binary Tree Level Order Traversal II 二叉树层次遍历与倒转

题目描述:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null,15...

2018-03-24 20:32:25 243

原创 Leetcode 104 Maximum Depth of Binary Tree 二叉树的最大深度

题目描述:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.For example:Given binary tree [3,9,20...

2018-03-24 20:25:23 137

原创 Leetcode 101 Symmetric Tree 判断一棵树是否对称

题目描述:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3Bu...

2018-03-24 20:20:40 203

原创 Leetcode 100 Same Tree 判断两棵树相同

题目描述:Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.给出两个二叉树...

2018-03-24 20:13:50 182

原创 利用sklearn进行豆瓣电影评论的文本分类

    在之前,我已经在豆瓣电影top250中爬取了约6w条好评和差评,在此我们来利用这些数据,进行入门级别的文本分类。一 数据清洗    数据在豆瓣电影top250提供下载,下载后能看到6W条好评和差评,由于爬取时未能完全清除符号,导致一部分毫无意义的颜文字评论混入其中,为了清除这些数据,我在(仅当数据量较小的情况下)excel中替换掉了肉眼可见的一些符号,然后转换成xlsx格式(csv中出现中...

2018-03-24 19:59:04 3990

翻译 Python Numpy 快速入门指导 (四) 进阶操作

    本文乃Numpy Quickstart tutorial的翻译版本(并非完全翻译,翻译君为本人),英语能力足够的童鞋请阅读原文~,如果您觉得本文对您有帮助的话不要忘记点个赞哦!一 神奇的广播操作    numpy的一些universal操作要求被操作的两个数组需要拥有相同的形状,如果两者的形状不相同的时候,则会调用广播功能,规则如下:    1.当输入数组的维数不同时,不断地给数组的较小维...

2018-03-24 10:04:22 449

翻译 Python Numpy 快速入门指导 (三) 理清numpy什么时候会复制出一个新的数组?

    本文乃Numpy Quickstart tutorial的翻译版本(并非完全翻译,翻译君为本人),英语能力足够的童鞋请阅读原文~,如果您觉得本文对您有帮助的话不要忘记点个赞哦!    numpy在进行一些操作时,有时数组会被复制到新的数组,但是有的时候并不会这样做,对于初学者来说,这可能很混乱。现在我们就来辨别一下这些情况吧!一 不会复制到新的数组的情况    简单的赋值操作不会复制到新的...

2018-03-24 09:06:25 306

翻译 Python Numpy 快速入门指导 (二) 形状操作

    本文乃Numpy Quickstart tutorial的翻译版本(并非完全翻译,翻译君为本人),英语能力足够的童鞋请阅读原文~,如果您觉得本文对您有帮助的话不要忘记点个赞哦!一 改变多维数组的形状    首先创建一个你所想要大小的多维数组>>> a = np.floor(10*np.random.random((3,4)))>>> aarray([...

2018-03-23 19:07:48 383

原创 Leetcode 35 Search Insert Position 二分查找插入数字位置

题目描述:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array...

2018-03-23 12:42:08 220

原创 Leetcode 28 Implement strStr() 字符串匹配

题目描述:Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2Example 2:In...

2018-03-23 12:32:18 145

原创 Leetcode 27 Remove Element

题目描述:Given an array and a value, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-p...

2018-03-23 09:24:41 120 1

原创 Leetcode 88 Merge Sorted Array 合并两个有序数组

题目描述:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additi...

2018-03-23 09:17:56 181

翻译 Python Numpy 快速入门指导 (一) 基础

    本文乃Numpy Quickstart tutorial的翻译版本(并非完全翻译,翻译君为本人),英语能力足够的童鞋请阅读原文~,如果您觉得本文对您有帮助的话不要忘记点个赞哦!一 预先准备      在阅读本文之前,请先确保您已经有了一些python基础,如果没有的话,请看Python Tutorial,安装在此跳过。二 基础    numpy的操作对象通常是齐次的多维数组,数组的每一个元...

2018-03-23 00:03:01 284

原创 yande.re 爬虫 自动爬取网站上的图片

    最近想要自动下载一些東方project同人图,看了看几家同人图网站,最后想先拿yande.re试手,不用登陆,页面上也没有乱七八糟的广告混淆视听,而且图片普遍质量很高,以下是代码:    如果有想用的,直接修改tag,文件保存路径,页数就可以直接用了import urllibimport urllib.requestimport reimport timeimport osdef...

2018-03-23 00:02:44 24204 2

原创 Leetcode 83 Remove Duplicates from Sorted List 有序链表去重

题目描述:Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.思路:...

2018-03-22 10:00:41 165

原创 Leetcode 70 Climbing Stairs 爬楼梯的方法(动态规划)

题目描述:You are climbing a stair case. It takes n steps 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?Note: Given n will be a positiv...

2018-03-22 09:58:20 334

原创 Leetcode 69 Sqrt(x) 求x开根号的整数部分

题目描述:Implement int sqrt(int x).Compute and return the square root of x.x is guaranteed to be a non-negative integer.Example 1:Input: 4Output: 2Example 2:Input: 8Output: 2Explanation: The square roo...

2018-03-22 09:54:16 677

原创 Leetcode 67 Add Binary 二进制加

题目描述:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".用两个string表示大数,返回他们的和(也用string)思路:    1.不用想,这道题用string肯定是有坑的,很有可能输入的string很长,远远超过了long lon...

2018-03-22 09:47:39 117

原创 Leetcode 66 Plus One

题目描述:Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digits ...

2018-03-22 09:40:12 107

原创 Leetcode 58 Length of Last Word 句子中最后一个词的长度

题目描述:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defi...

2018-03-22 09:34:06 156

原创 Leetcode 53 Maximum Subarray 最大子串和

题目描述:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4,-1,2,1] has...

2018-03-22 09:30:08 202

原创 Leetcode 38 Count and Say

题目描述:The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as "one 1" or 11.11 is read off ...

2018-03-22 09:16:41 97

原创 Leetcode 26 Remove Duplicates from Sorted Array 有序向量中的去重

题目描述:Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifying...

2018-03-22 09:08:14 97

原创 Leetcode 21 Merge Two Sorted Lists 将两个已排序的链表合并起来

题目描述: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.把两个已经排序的链表合并起来,合并后仍然要有序Input: 1->2->4, 1->3-&...

2018-03-22 09:00:30 157

原创 豆瓣电影top250下的评论爬取

    近日想要试试文本分类的小demo,需要有足够大量的好评差评数据,在研究了一些点评网站后,我选择了豆瓣电影top250豆瓣电影TOP250,这个网上的评价质量高,而且网页结构清晰明显,好爬取。美中不足的是每个电影的评价(好评以及差评)只能爬取各前200条,并且爬了太多(估计是访问100页左右)之后就封IP,一天后解封。后来换了手机提供的WLAN热点之后就再也没有封得掉我,不知道其中是什么原理...

2018-03-21 19:42:13 5043 4

原创 Leetcode 20 Valid Parentheses 判断括号匹配

题目描述:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all valid...

2018-03-21 18:15:43 158

原创 Leetcode 14 寻找字符串之间的最长前缀

题目描述:Write a function to find the longest common prefix string amongst an array of strings.有许多字符串,寻找他们之间的最长的公共前缀思路:1.将n个字符串的比较转化为2个之间的,n个之间的无非是两两比较得到结果的最小值2.假设有m个字符串,每个字符串n长度,时间复杂度O(mn),空间复杂度O(1)源代码:c...

2018-03-21 18:10:37 472

原创 Leetcode 13 Roman to Integer 罗马数字转整数

题目描述:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.将一段string的罗马数字转换到整数,输入数字在1-3999之间思路:1.原来的思路十分麻烦,需要匹配大量的情况,但是看到讨论区的大神的代码后瞬间佩服的五体投地,再也不敢把自己...

2018-03-21 18:02:45 247

原创 Leetcode 9 Palindrome Number 判断一个数是否为回文数

题目描述:Determine whether an integer is a palindrome. Do this without extra space.判断一个数是否是回文数(正着读和反着读一样),负数没有回文数思路:1.取a=输入数。令b=0,是a的倒转形式每次b乘以10,以表示b向左移动一次,取a的最后一位数字加到b中,做完后a除以10,表示下一次可以取出a 的左面一位。假设a=121,...

2018-03-21 17:54:15 310

原创 Leetcode 7 Reverse Integer 将整数逆转

题目描述:Given a 32-bit signed integer, reverse digits of an integer.给一个int整数,将数字部分反转,符号不变,翻转后溢出则返回0思路:1.利用string作为中转,反转数字2.保证函数总是反转x的绝对值,减少判断。3.最开始将所有的末尾0去掉(除以10即可),免得翻转后开头出现04.时间复杂度O(lgn),空间复杂度O(lgn),n为...

2018-03-21 17:46:47 258

原创 Leetcode 1 Two Sum 两数之和

题目描述:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the sa...

2018-03-20 23:43:05 279

空空如也

空空如也

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

TA关注的人

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