Leetcode-11 Posted on 2019-06-03 | Words count in article: 78 | Reading time ≈ 1 Question Solution建立两个指针,从左右向中间遍历。用宽度来循环。 123456789class Solution: def maxArea(self, height: List[int]) -> int: l, r, width, res = 0, len( ... Read more »
Leetcode-8 Posted on 2019-06-03 | Words count in article: 106 | Reading time ≈ 1 Question Solution首先用strip去掉str前面的空格,然后判断是否为空。之后根据第一个元素判断正负。然后就是读取数据了。 12345678910111213141516class Solution: def myAtoi(self, str: str) -> int: ... Read more »
Leetcode-5 Posted on 2019-06-03 | Words count in article: 108 | Reading time ≈ 1 Question Solution1遍历总长度。选定一个index后,建立两个指针,向左右两边遍历,判断是否相等。 1234567891011121314151617class Solution: def longestPalindrome(self, s: str) -> str: ... Read more »
Decision Tree Posted on 2019-05-24 | Words count in article: 773 | Reading time ≈ 2 决策树的直观解释决策树就是通过一系列的特征来判断其属性,我们以苹果为例。 在买苹果的时候,我们会通过苹果的颜色、硬度、香味来判断是不是好苹果。例如我们有以下的数据: 颜色 硬度 香味 结论 1 红色 硬 香 是 2 红色 硬 无味 是 3 红色 软 无味 否 4 绿色 ... Read more »
Python Pandas Posted on 2019-05-22 | Words count in article: 622 | Reading time ≈ 2 将表组合起来12pd.concat([df1, df2, df3], axis = 0)#0是在行叠加,1是列叠加 1234567891011pd.merge(left, right, how = 'inner', left_on=None, right_on=None, left_index=Fa ... Read more »
Python Numpy Posted on 2019-05-22 | Words count in article: 438 | Reading time ≈ 1 numpy数组array:一系列同类型的数据的集合,被非零整数进行索引123456789101112131415161718192021222324a = np.array([[1,2,3],[1,2,3]])#如果有其他类型的数值,会被强制转换np.arange(1,10)[out] array( ... Read more »
Python Basic Operation Posted on 2019-05-22 | Words count in article: 1.9k | Reading time ≈ 10 Basic Operation 安装某一个包, terminal里面打 pip install name 自定义函数 1234567891011121314151617181920212223242526272829303132333435def soton_fun1(x1,x2): ret ... Read more »
MySQL 知识点 Posted on 2019-05-09 | Words count in article: 2.6k | Reading time ≈ 11 1. 数据库的选择假设数据名字为crashcourse,customers为其中的一张表。其中,最后两句话是相等的。 12345USE crashcourseSHOW databaseSHOW TABLESSHOW COLUMNS FROM customersDESCRIBE customers 2 ... Read more »
Leetcode 74 Posted on 2019-04-27 | Words count in article: 94 | Reading time ≈ 1 Question Solution因为matrix是排好序的,将其转化为一维列表,然后用二分法查找。 1234567891011121314151617class Solution: def searchMatrix(self, matrix: List[List[int]], target: ... Read more »
Leetcode 34 Posted on 2019-04-26 | Words count in article: 193 | Reading time ≈ 1 Question Solution二分查找。 找到mid=target的位置。然后查找mid附近的等于target的数的index。 首先令n=m=mid。采用while来找到对应的index。如果mid前面的数等于target,则n-=1。这里需要注意一种情况,即首位就等于target。所以额外添 ... Read more »