自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

BLUE BOX

计算机视觉,推荐系统,强化学习

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

原创 jupyter notebook一个很好用的Python笔记本

原来很多平台用的在线编译的东西就是jupyter 这个工具集成了代码运行和makedown的功能,所以可以来用做代码的实现和做笔记的功能,并且写过的代码还可以修改再运行,简直不要太方便。 但是有一点就是还不知道如何导出pdf。并且想导入到Evernote中也不可以。 下面看看这个东西的界面。 其他的可以自己探索哦,网上有很多好的教程。下面有几个教程可以参考。推荐教程https://www.i

2017-05-29 11:09:55 3748

原创 mac 中python的anaconda包管理

但我们安装了anaconda以后,我们使用ipython时我们所用的模块的路径都是anaconda的路径,并且我们用pip安装的模块都不能再ipython中使用。Anaconda利用工具/命令conda来进行package和environment的管理,并且已经包含了Python和相关的配套工具。 conda 就好想pip一样,我们安装包的时候也使用 conda install numpy这样的命

2017-05-29 10:16:25 11483

原创 数据科学的七个工作流程

工作流程(workflow stages)问题的定义获取训练和测试数据数据准备、清洗分析,识别模式和探索数据模型,预测和解决问题可视化,报告,和呈现问题解决步骤和找到解决方案提供或提交结果这个工作流程提供了每个阶段的下一个步骤。但是没什么东西是绝对的。我们可以结合各个工作流程步骤,我们可以通过可视化分析数据。把有些步骤先执行,我们可以先分析数据然后再进行数据

2017-05-26 11:25:56 8253

原创 动态规划

动态规划的描述动态规划通常基于一个递推公式及一个或多个初始状态。当前子问题将由上一子问题的解推出。状态与状态转移方程“状态”用来描述该问题的子问题的解。 注意,大部分情况下,某个状态只与它前面出现的状态有关, 而独立于后面的状态。例题1一个序列有N个数:A[1],A[2],…,A[N],求出最长非降子序列的长度。 让我们沿用“入门”一节里那道简单题的思路来一步步找到“状态”和“状态转移方程”。

2017-05-26 11:24:07 259

原创 202. Happy Number

202. Happy NumberWrite an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of

2017-05-18 23:57:57 194

原创 121. Best Time to Buy and Sell Stock

121. Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one an

2017-05-18 15:21:07 192

原创 108. Convert Sorted Array to Binary Search Tree--二叉查找数

108. Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.# Definition for a binary tree node.# class TreeNode(obj

2017-05-18 15:01:10 188

原创 350. Intersection of Two Arrays II -- 双指针、哈希表、排序、二分搜索

350. Intersection of Two Arrays IIGiven two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]解1:双指针,并把结果添加到栈中。class Solution(obje

2017-05-17 09:52:55 336

原创 206. Reverse Linked List--链表翻转

链表翻转该开始想了很久,看代码也是乱,后来发现其实就是从前到后依次翻转箭头的指向,首先把第一个表指向第二个表的箭头翻转为指向None的箭头,head指向第二个表。 current相当于交换两杯水的中间的水杯。 用于存储中间变量。# Definition for singly-linked list.# class ListNode(object):# def __init__(sel

2017-05-16 14:53:43 305

原创 169. Majority Element -- 字典

169. Majority ElementGiven an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the maj

2017-05-16 11:03:26 187

原创 122. Best Time to Buy and Sell Stock II -- greedy

122. Best Time to Buy and Sell Stock II很有意思的一道题目 怎么利益最大化? 贪婪算法就是要把问题分解成小问题,把全局最优集问题分为一个个局部最优解的小问题。 那么把全局利益最大化,转换为当前的局部利益最大,当第二天比第一天价格高的时候就第一天买和第二天卖,当第二天比第一天价格低的时候就不动。Say you have an array for which

2017-05-16 00:06:58 216

原创 387. First Unique Character in a String -- 哈希表、字典

387. First Unique Character in a String – 哈希表、字典注:涉及到统计个数之类的题目,大部分都可以使用字典(hashmap)来解。Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.E

2017-05-15 23:36:13 179

原创 349. Intersection of Two Arrays --双指针、字典、二分查找、集合

349. Intersection of Two Arrays很经典的题目,可以使用双指针、字典、二分查找、集合来实现Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Solution 1:us

2017-05-15 00:31:49 316

原创 167. Two Sum II - Input array is sorted -- 双指针、字典、二分搜索

167. Two Sum II - Input array is sortedGiven an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum shoul

2017-05-14 21:21:16 211

原创 455. Assign Cookies -- 贪心算法

455. Assign Cookies – 贪心算法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

2017-05-14 20:13:36 340

原创 258. Add Digits -- 递归、字符串分解

258. Add DigitsGiven a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has on

2017-05-14 19:59:55 233

原创 226. Invert Binary Tree -- 二叉树、递归、交换、栈

226. Invert Binary TreeInvert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1解一: 又是一个二叉树问题,这次直接想到了递归,并且确定停止条件和执行的命令,返回的参数。# Definitio

2017-05-12 00:19:14 277

原创 371. Sum of Two Integers

371. Sum of Two IntegersCalculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3.解1: 厉害了,不使用加减,计算两个整数的和。 那么是否可以使用operato

2017-05-12 00:12:45 196

原创 389. Find the Difference --字符串的共同字符

389. Find the DifferenceGiven two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the l

2017-05-11 23:42:47 202

原创 104. Maximum Depth of Binary Tree -- 二叉数、递归

104. Maximum Depth of Binary TreeGiven 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.解1: 经典的二叉

2017-05-11 10:45:03 239

原创 448. Find All Numbers Disappeared in an Array -- set

448. Find All Numbers Disappeared in an ArrayTotal Accepted: 40636Total Submissions: 77545Difficulty: EasyContributors:yuhaowang001Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array)

2017-05-11 10:09:26 171

原创 136. Single Number--字典、找单身狗

136. Single Number在情侣中找出单身狗,对单身狗暴击。Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you i

2017-05-10 23:39:33 219

原创 485. Max Consecutive Ones -- array、栈

485. Max Consecutive OnesGiven a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digi

2017-05-10 23:17:46 149

原创 496. Next Greater Element I -- 栈

496. Next Greater Element IYou are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corres

2017-05-10 10:27:03 191

原创 344. Reverse String

344. Reverse StringWrite a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".解: 可以直接用python的字符串处理,也可以用交换字符的位置来完成,交换位置的话需要先把字符串拆分成一个个字符,因为

2017-05-09 21:58:55 123

原创 412. Fizz Buzz

412. Fizz Buzz这是一题使用判断条件的题目,还考察了求余数,我使用了map()方法。Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number an

2017-05-09 21:49:12 172

原创 500. Keyboard Row

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

2017-05-09 21:24:09 195

原创 557. Reverse Words in a String III

Reverse Words in a String IIIGiven a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's

2017-05-09 13:33:37 226

原创 575. Distribute Candies

575. Distribute CandiesGiven an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You ne

2017-05-09 10:54:54 295

原创 461. Hamming Distance

461. Hamming Distanceclass Solution(object): def hammingDistance(self, x, y): """ :type x: int :type y: int :rtype: int """ x_bin = bin(x).replace('0

2017-05-08 19:36:41 149

原创 561. Array Partition I

561. Array Partition IGiven an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1

2017-05-08 18:38:48 170

原创 Leetcode刷题前奏

被笔试题虐过之后奋发图强,立志增强编程能力,不被笔试题虐。刷题计划:按难度刷easy–>hard,增加题型多样性每天刷个一题多学多看

2017-05-08 11:17:11 173

原创 算法学习笔记--排序之快速排序

算法学习笔记–排序之快速排序定义快速排序使用了分而治之的策略。使用分而治之解决问题的两个步骤?找出停止条件,这种条件尽可能简单。不断将问题分解(或者说缩小规模),直到符合停止条件。实现def quick_sort(array): if len(array) < 2: return array else: pivot = array[0]

2017-05-07 12:09:31 218

原创 算法学习笔记–递归(2)之栈

算法学习笔记–递归(2)之栈调用栈的概念计算机内部使用被称之为调用栈的栈,在执行每个函数的时候,计算机都会为函数分配一块内存,当执行到这个函数中的一个函数时,计算机会给函数中的函数分配一个新的内存,并且第二块内存位于第一个内存上面,当函数调用完后,栈顶的内存被弹出。然后继续执行外部的函数。递归是如何使用调用栈的?每次调用递归函数,将会把函数压入栈顶,等到到达停止调节的时候,依次从调用栈顶弹出。

2017-05-07 11:35:36 327

原创 算法学习笔记--递归(1)

算法学习笔记–递归定义自身调用自身。要实现一个递归函数,那么必须满足两个条件,停止条件和递归条件。递归条件是指函数调用自己,而停止条件是什么时候停止调用,停止无限循环。这两个条件使用if….else….语句来执行实现例如:倒计时程序def count_down(num): print num num -= 1 if num < 0: return el

2017-05-07 11:15:22 223

原创 算法学习笔记--排序之选择排序

算法学习笔记–排序之选择排序定义选择排序需要额外的存储空间,且排序的时间为O(N^2),其实为O(1/2(N^2))但是常数可以省略。 选择排序每次都遍历一遍剩下的数,然后选出最小的一个数放到排序好的存储空间中去。实现python中没有数组,所以用列表(List)代替。def find_smallest(array): smallest = array[0] for i in ra

2017-05-07 10:53:42 225

原创 算法学习笔记--动态规划(1)

算法学习笔记–动态规划学习目标学习动态规划,它将问题分成小问题,并先着手解决这些小问题。学习如何设计问题的动态规划解决方案动态规划解法画网格解可以解决的问题需要在给定约束条件下优化某种指标 问题可以分解为离散子问题时,背包问题–给定限制条件计算最优解 最长公共子串–例如比较两个文件的差异性总结每种动态规划解决方案都涉及网格 每个单元格都是一个子问题,因此要思考如何将问题分解为子问题 没

2017-05-06 23:09:17 279

原创 算法学习笔记--NP完全问题

算法学习笔记–NP完全问题什么是NP完全问题?简单来说就是非常难解的问题,无法找到一个快速解决的算法,如旅行商问题和集合覆盖问题。如何判断一个问题是NP问题?NP问题无处不在,如果能够判断一个问题是NP完全问题,那么我们就不需要去寻找完美的解决方案,而是寻找一个近似算法即可。往往有时候易于解决的问题和NP完全问题的差别很小。如何判断NP问题有一些点可参考:元素较少时算法的运算速度很快,当随着元素数

2017-05-06 21:57:25 1117

原创 算法学习笔记--贪婪算法

算法学习笔记–贪婪算法学习目标如何处理不可能完成的任务:没有快速算法的问题识别NP完全问题,以免浪费时间去寻找快速算法学习近似算法,可以快速找到NP完全问题的近似解学习贪婪策略,一种非常简单的问题解决策略什么是贪婪算法?贪婪算法就是每一步都采取最优的做法。 也可以说是每一步都是选择的局部最优解。背包问题幂集设有集合A,由A的所有子集(包括空集)组成的集合,称为A的幂集,记作2^A 。

2017-05-06 21:43:52 740 1

原创 算法学习笔记--狄克斯特拉算法

算法学习笔记–狄克斯特拉算法主要内容加权图:提高或降低某些边的权重介绍狄克斯特拉算法,能找出加权图中前往X的最短路径图中的环会导致狄克斯特拉算法不管用,如果有负权重也不适用 如果要处理负权重的图,可以使用贝尔曼-福德算法狄克斯特算法的四个步骤找出最便宜的节点,即可在最短时间内到达的节点对于该节点的邻居,检查是否有前往它们的更短路径,如果有,就更新其开销。重复这个过程,直到对图中的每个

2017-05-06 20:52:29 1577 1

空空如也

空空如也

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

TA关注的人

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