- 博客(167)
- 资源 (1)
- 收藏
- 关注
原创 力扣_152. 乘积最大子序列 定义当前结点位置的最大值和最小值,判断后续新来的值,不断更新当前结点位置的最大值和最小值
题目:给定一个整数数组 nums,找出一个序列中乘积最大的连续子序列(该序列至少包含一个数)。示例 1:输入: [2,3,-2,4]输出: 6解释:子数组 [2,3] 有最大乘积 6。示例 2:输入: [-2,0,-1]输出: 0解释:结果不能为 2, 因为 [-2,-1] 不是子数组。代码:class Solution(object): de...
2019-08-30 18:35:15
278
原创 力扣_98. 验证二叉搜索树 添加一个函数,增加上下界来判断左子树和右子树是否是二叉搜索树
题目:给定一个二叉树,判断其是否是一个有效的二叉搜索树。假设一个二叉搜索树具有如下特征:节点的左子树只包含小于当前节点的数。节点的右子树只包含大于当前节点的数。所有左子树和右子树自身必须也是二叉搜索树。示例1:输入: 2 / \ 1 3输出: true示例2:输入: 5 / \ 1 4 / \ 3 ...
2019-08-30 16:43:47
343
原创 力扣_16. 最接近的三数之和, 双指针法
题目:给定一个包括n 个整数的数组nums和 一个目标值target。找出nums中的三个整数,使得它们的和与target最接近。返回这三个数的和。假定每组输入只存在唯一答案。例如,给定数组 nums = [-1,2,1,-4], 和 target = 1.与 target 最接近的三个数的和为 2. (-1 + 2 + 1 = 2).代码:class S...
2019-08-30 15:37:41
298
原创 LeetCode_34. Find First and Last Position of Element in Sorted Array 在有序数组中查找某数字的起始和终止下标
题目:Given an array of integersnumssorted in ascending order, find the starting and ending position of a giventargetvalue.Your algorithm's runtime complexity must be in the order ofO(logn).I...
2019-04-29 16:41:27
259
原创 LeetCode_33. Search in Rotated Sorted Array 在有一个转折的有序数组中查找某元素,二分法
题目:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e.,[0,1,2,4,5,6,7]might become[4,5,6,7,0,1,2]).You are given a target value to search. If f...
2019-04-26 17:05:11
217
原创 LeetCode_29. Divide Two Integers 不用乘、除、模运算来实现两个数的除法
题目:Given two integersdividendanddivisor, divide two integers without using multiplication, division and mod operator.Return the quotient after dividingdividendbydivisor.The integer divisio...
2019-04-26 15:14:02
257
原创 LeetCode_17. Letter Combinations of a Phone Number 手机号码的字母组合,回溯法
题目:Given a string containing digits from2-9inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) i...
2019-04-23 16:13:37
180
原创 LeetCode_15. 3Sum 求3个数字之和为0的所有情况的组合
题目:Given an arraynumsofnintegers, are there elementsa,b,cinnumssuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not...
2019-04-23 15:19:25
470
转载 软件测试的一些基本概念
软件测试主要工作内容是验证(verification)和确认(validation),下面分别给出其概念:验证(verification)是保证软件正确地实现了一些特定功能的一系列活动, 即保证软件以正确的方式来做了这个事件(Do it right)1.确定软件生存周期中的一个给定阶段的产品是否达到前阶段确立的需求的过程。2.程序正确性的形式证明,即采用形式理论证明程序符合设计规约规定的过程...
2019-04-19 15:09:08
424
原创 LeetCode_11. Container With Most Water 求坐标中所有点能够成的最大容量(双指针法,计算左右两侧指针确定的区域面积,高度小的指针更新)
题目:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of lineiis at (i,ai) and (i, 0). Fin...
2019-04-16 16:05:23
288
原创 Leetcode_8. String to Integer (atoi) 字符串转化为整数(空格、正负号、数字、字符串等的处理)
题目:Implementatoiwhichconverts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting fro...
2019-04-15 15:41:50
376
原创 Leetcode_5. Longest Palindromic Substring 查找字符串里的最长回文子串(遍历每个元素,两边扩展搜索,返回最长回文长度,标记最长回文两端)
题目:Given a strings, find the longest palindromic substring ins. You may assume that the maximum length ofsis 1000.Example 1:Input: "babad"Output: "bab"Note: "aba" is also a valid answer....
2019-04-12 15:07:12
130
原创 Leetcode_4. Median of Two Sorted Arrays 求两个有序数组的中位数
题目:There are two sorted arraysnums1andnums2of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).You may assumenums1...
2019-04-11 15:34:47
136
原创 Leetcode_3. Longest Substring Without Repeating Characters 求一个字符串中最长不重复子串的长度(移动窗口法)
题目:Given a string, find the length of thelongest substringwithout repeating characters.Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. Exampl...
2019-04-11 10:20:57
261
原创 leetcode_2. Add Two Numbers 求单链表表示的两个数相加的和,也用单链表表示(数字全部倒序表示)
class Solution(object):def addTwoNumbers(self, l1, l2):“”":type l1: ListNode:type l2: ListNode:rtype: ListNode“”" if l1 == None and l2 == None : return "It's empty!" carry = 0 ...
2019-04-08 17:15:13
246
原创 leetcode_1. Two Sum 返回两数组中和为固定数值的数字的下标
class Solution(object):def twoSum(self, nums, target):“”":type nums: List[int]:type target: int:rtype: List[int]“”" if len(nums) <= 1 : return "Error!" temp_dict = {} ...
2019-04-08 10:33:48
283
转载 各种机器学习方法(线性回归、支持向量机、决策树、朴素贝叶斯、KNN算法、逻辑回归)实现手写数字识别并用准确率、召回率、F1进行评估
本文转自:http://blog.youkuaiyun.com/net_wolf_007/article/details/51794254机器学习实践之手写数字识别 - 数据初识2. 机器学习实践之手写数字识别 - 初步特征选择及线性识别前面两章对数据进行了简单的特征提取及线性回归分析。识别率已经达到了85%, 完成了数字识别的第一步:数据探测。这一章要做的就各种常用机器学
2017-09-07 21:51:13
8848
1
转载 sklearn中的模型评估
本文转载自http://d0evi1.com/sklearn/model_evaluation/1.介绍有三种不同的方法来评估一个模型的预测质量:estimator的score方法:sklearn中的estimator都具有一个score方法,它提供了一个缺省的评估法则来解决问题。Scoring参数:使用cross-validation的模型评估工具,依赖于
2017-09-07 11:12:56
3967
转载 二类分类问题评价指标
1. 准确率评价分类问题的性能的指标一般是分类准确率,其定义是对于给定的数据,分类正确的样本数占总样本数的比例。但是这一指标在Unbalanced的数据上表现很差。比如说我的样本有990个正样本,10个负样本,我直接把所有样本都预测为正,我的准确率为99%,居然有这么高得准确率,但我的分类方法实际是非常不具有说服力的。2. 精确率和召回率对于二分类问题常用的评价指标是精确率和召回率
2017-09-06 16:56:25
6046
原创 scrapy框架爬取京东商城商品的评论
一、Scrapy介绍Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架。 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中。所谓网络爬虫,就是一个在网上到处或定向抓取数据的程序,当然,这种说法不够专业,更专业的描述就是,抓取特定网站网页的HTML数据。抓取网页的一般方法是,定义一个入口页面,然后一般一个页面会有其他页面的URL,于是从当前页面获取到这些URL加
2017-04-12 10:27:22
3390
转载 Scrapy在win7 32位的安装及依赖包
博客转自:http://www.cnblogs.com/liyiran/p/4454891.htmlScrapy,一个网络爬虫的框架,首先第一步肯定是安装。参考网上的文章。安装过程中需要用到pip工具,请自行安装。1.安装python这个是必须的,既然都用到scrapy了,肯定已经安装了python,这个略过。2.安装pywin32下载地址:
2017-04-10 21:24:59
663
原创 K-means 与 KNN
K-means 与 KNN 是两个很简单的算法,但是由于平时用的少,所以记得不是很清楚,稍不注意,就会弄混,现在特别对这两个算法进行比较学习。1、K-meansK-means 是一种聚类算法,将已知的样本按照K个类来聚类。K-Means的算法如下:1、随机在图中取K(想要聚成几个类,K就等于几)个种子点。2、然后对图中的所有点求到这K个种子点的距离,假如点Pi离种
2017-03-21 20:57:13
500
转载 长短记忆型递归神经网络LSTM
原文链接http://www.youkuaiyun.com/article/2015-11-25/2826323?ref=myread摘要:作者早前提到了人们使用RNNs取得的显著成效,基本上这些都是使用了LSTMs。对于大多数任务,它们真的可以达到更好的效果!写了一堆方程式,LSTMs看起来很吓人。希望通过这篇文章中一步一步的剖析,能更好理解它们。递归神经网络人类并不是每时每刻都从头开始思考。正如你阅读这
2017-03-16 17:23:29
1584
原创 狄利克雷分布(The Dirichlet Distribution) 及其相关
必备的一些基础概念:先验概率(prior probability) p(θ) :先验概率是在获取某些信息前,对变量p的不确定性进行猜测,仅仅依赖主观上的经验估计,也就是事先根据已有的知识的推断。例如,已知某学校男生占60%,女生占40%。现给定一个该学校的学生,问ta是男生还是女生。我们只能根据之前的认识,得出是男生还是女生的概率分别为0.6和0.4,这就是先验概率。似
2017-03-13 17:56:54
1653
原创 leetcode_500. Keyboard Row 判断字符串能否由键盘上同一行的字母组成
题目:Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.Example 1:Input: ["Hello", "Alaska",
2017-03-10 20:31:34
1048
原创 leetcode_481. Magical String 魔法数字,找字符串中的1,2数字规律
题目:A magical string S consists of only '1' and '2' and obeys the following rules:The string S is magical because concatenating the number of contiguous occurrences of characters '1' and '2'
2017-02-25 22:00:51
843
转载 leeocode_503. Next Greater Element II
503. Next Greater Element IIGiven a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number
2017-02-22 22:01:02
322
原创 leetcode_476. Number Complement 求数的补码
题目:Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note:The given integer is guaranteed to fit within t
2017-01-13 23:21:55
420
原创 leetcode_445. Add Two Numbers II 单链表表示的两个大数相加
题目:You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and
2017-01-05 20:51:41
1535
原创 leetcode_462. Minimum Moves to Equal Array Elements II 移动最小步数使数组各数字相等II,中位数法
题目:Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected el
2017-01-05 16:07:57
1386
原创 leetcode_442. Find All Duplicates in an Array 找数组中出现两次的数,正负号标记法
题目:Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it w
2016-12-29 16:00:13
753
原创 leetcode_20. Valid Parentheses 括号匹配问题;java String实例的声明和初始化;没用栈;
题目: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 val...
2016-12-23 17:18:45
343
原创 leetcode_434. Number of Segments in a String 计算字符串中段的个数,只需遍历一遍字符串
题目:Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.Please note that the string does not contain any non-printable cha
2016-12-22 17:22:46
406
原创 leetcode_459. Repeated Substring Pattern 重复子串模式,判断某个字符串能否由某个字串重复若干次组成
题目:Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowerc
2016-12-21 22:16:31
2445
原创 leetcode_455. Assign Cookies 分配饼干,java数组的排序
题目:Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum si
2016-12-21 20:50:58
781
原创 leetcode_463. Island Perimeter 计算岛的周长
题目:You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is co
2016-12-21 10:35:55
571
原创 leetcode_448. Find All Numbers Disappeared in an Array 找出不在数组中的数,正负号标记法
题目:Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this a
2016-12-20 22:24:26
805
原创 leetcode_461. Hamming Distance 计算汉明距离,按位异或运算,计算整数的二进制表示中1的个数 java
题目:The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.Note:
2016-12-20 21:12:18
5709
原创 随机梯度下降算法
BP神经网络是神经网络的基础,其中可用随机梯度下降算法来加快更新权值和偏置,但是随机梯度下降算法总是忘记,下面来好好复习一下: ⼈们已经研究出很多梯度下降的变化形式,包括⼀些更接近真实模拟球体物理运动的变化形 式。这些模拟球体的变化形式有很多优点,但是也有⼀个主要的缺点:它最终必需去计算代价函数C的 ⼆阶偏导,这代价可是⾮常⼤的。为了理解为什么这种做法代价⾼,假设我们想求所有的⼆阶偏导
2016-12-08 21:36:30
12915
1
原创 leetcode_424. Longest Repeating Character Replacement 求替换k个字符后连续相同字符子串的长度,滑动窗口的应用
题目:Given a string that consists of only uppercase English letters, you can replace any letter in the string with another letter at most k times. Find the length of a longest substring containing
2016-12-08 17:35:50
858
支持向量机和支持向量回归
2016-11-24
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人