自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(55)
  • 收藏
  • 关注

原创 强连通分量

Description贝爷的人生乐趣之一就是约战马会长. 他知道马会长喜欢和怪兽对决,于是他训练了N只怪兽,并对怪兽用0到N-1的整数进行编号. 贝爷训练怪兽的方式是让它们一对一互殴. 两只怪兽互殴会发生以下三种可能的结果:1) 什么事也没发生2) 第一只怪兽永远消失3) 第二只怪兽永远消失怪兽们经过了旷日持久的互殴. 贝爷不知道哪些怪兽进行了互殴也不知道它们互殴的顺序,但他确信无论经过...

2019-09-26 11:19:34 132

原创 LeetCode 120. Triangle

题目链接Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], ...

2018-12-12 13:59:56 154

原创 LeetCode 773. Sliding Puzzle--BFS

求最短的step这类问题可以用BFS解决,我的博客也有一道类似的题目跳蚱蜢 773. Sliding PuzzleOn a 2x3 board, there are 5 tiles represented by the integers 1 through 5, and an empty square represented by 0.A move consists of choo...

2018-09-17 15:31:54 502

原创 LeetCode 200. Number of Islands&130. Surrounded Regions--DFS

两道题应该分别是我在蓝桥杯和南大夏令营遇到的原题,比较相似题目链接200. Number of IslandsGiven a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connect...

2018-08-14 18:39:55 165

原创 LeetCode 310. Minimum Height Trees--Graph

题目链接For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are calle...

2018-07-22 00:59:26 136

原创 Playing atari with deep reinforcement learning

Introduction传统RL手动提取选择特征,DL(CNN)可以根据raw sensory的数据抽象出一些high-level特征,DRL的困难:DL训练使用大量的labeled数据,而RL数据量小,且reward和action之间的delayDL样本间独立,RL样本间相关RL样本的分布随着学习改变,DL中设定的固定的分布本文针对2,3困难的方法: experience...

2018-04-10 14:35:53 868

原创 蓝桥杯 跳蚱蜢

如图 p1.png 所示: 有9只盘子,排成1个圆圈。其中8只盘子内装着8只蚱蜢,有一个是空盘。我们把这些蚱蜢顺时针编号为 1~8每只蚱蜢都可以跳到相邻的空盘中,也可以再用点力,越过一个相邻的蚱蜢跳到空盘中。请你计算一下,如果要使得蚱蜢们的队形改为按照逆时针排列,并且保持空盘的位置不变(也就是1-8换位,2-7换位,...),至少要经过多少次跳跃?

2018-03-31 15:35:27 746 1

原创 蓝桥杯 剪邮票

剪邮票如【图1.jpg】, 有12张连在一起的12生肖的邮票。现在你要从中剪下5张来,要求必须是连着的。(仅仅连接一个角不算相连)比如,【图2.jpg】,【图3.jpg】中,粉红色所示部分就是合格的剪取。请你计算,一共有多少种不同的剪取方法。请填写表示方案数目的整数。注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。     

2018-03-31 13:27:51 433 1

原创 蓝桥杯 算法提高 学霸的迷宫

问题描述  学霸抢走了大家的作业,班长为了帮同学们找回作业,决定去找学霸决斗。但学霸为了不要别人打扰,住在一个城堡里,城堡外面是一个二维的格子迷宫,要进城堡必须得先通过迷宫。因为班长还有妹子要陪,磨刀不误砍柴功,他为了节约时间,从线人那里搞到了迷宫的地图,准备提前计算最短的路线。可是他现在正向妹子解释这件事情,于是就委托你帮他找一条最短的路线。输入格式  第一行两个整数n,

2018-03-30 20:11:05 115

原创 Reinforcement Learning - An Introduction memo

1.MDP(Markov Decision Processes)finite MDP: finite state space&finite action spacetransition probabilities:p(s′ | s, a) = Pr{St+1 = s′ | St = s, At = a}r(s, a, s′) = E[Rt+1 | St = s, At = a, St+1 = s′]

2018-03-26 21:31:01 219

原创 蓝桥杯 地宫取宝

问题描述  X 国王有一个地宫宝库。是 n x m 个格子的矩阵。每个格子放一件宝贝。每个宝贝贴着价值标签。  地宫的入口在左上角,出口在右下角。  小明被带到地宫的入口,国王要求他只能向右或向下行走。  走过某个格子时,如果那个格子中的宝贝价值比小明手中任意宝贝价值都大,小明就可以拿起它(当然,也可以不拿)。  当小明走到出口时,如果他手中的宝贝恰好是k件,则这些宝贝就可以送

2018-03-06 14:19:53 193

原创 蓝桥杯 方格填数

如下的10个格子填入0~9的数字。要求:连续的两个数字不能相邻。(左右、上下、对角都算相邻)一共有多少种可能的填数方案?解:回溯法,类似于数独那题,填每个数时判断是否存在冲突,不存在就可以继续填下一位置,结果是1580,c++代码:#include #include #include using namespace std;int leftA

2018-02-18 09:17:22 302

原创 LeetCode 44. Wildcard Matching--动态规划

题目链接44. Wildcard MatchingImplement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty

2018-01-13 21:36:45 565

原创 LeetCode 207. Course Schedule--Graph

题目链接207. Course ScheduleThere are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first tak

2018-01-11 18:12:43 168

原创 Sicily 1004. 拓扑序[Special judge]

Description在图论中,拓扑序(Topological Sorting)是一个有向无环图(DAG, Directed Acyclic Graph)的所有顶点的线性序列. 且该序列必须满足下面两个条件: 1.       每个顶点出现且只出现一次.2.       若存在一条从顶点 A 到顶点 B 的路径,那么在序列中顶点 A 出现在顶点 B 的前面. 对于一个含

2018-01-03 21:16:35 196

原创 KITE--NP-complete

8.19A kite is a graph on an even number of vertices, say 2n, in which n of the vertices form a clique and the remaining n vertices are connected in a "tail" that consists of a path joined to one of

2018-01-03 16:50:53 476

原创 LeetCode 141. Linked List Cycle

题目链接141. Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?解:满足 without using extra space这个要求的话,可

2017-12-24 17:16:46 117

原创 LeetCode 112. Path Sum--递归

题目链接112. Path SumGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the

2017-12-24 16:20:32 108

原创 LeetCode 60. Permutation Sequence

题目链接60. Permutation SequenceThe set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, f

2017-12-09 19:10:56 141

原创 LeetCode 236. Lowest Common Ancestor of a Binary Tree--递归

题目链接236. Lowest Common Ancestor of a Binary TreeGiven a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia:

2017-12-08 09:36:12 118

原创 LeetCode 87. Scramble String

题目链接87. Scramble StringGiven a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "grea

2017-12-05 21:03:22 122

原创 安卓E/CursorWindow: Failed to read row 0, column 0 from a CursorWindow which has 0 rows, 5 columns解决方案

使用SQLite数据库,建表插入数据后,使用Cursor读取时,发生以上错误,可见rows = 2,说明已经成功插入数据了,读的时候却说只有0 rows后来发现自己的问题是表中数据类型和插入的数据不完全吻合的问题我的表中有一个存放图片的BLOB类型,其实就是byte[],但是我将传的图片Bitmap 转byte[]指定了PNG压缩,但选择图片不小心选了JPG的,从而出现了以上报错,选了PN

2017-11-25 12:48:37 3303

原创 gzip过滤器源码分析

找gzip这个包就找了好久,最后在ubuntu下的 /home/usr/lib/go-1.6/src/compress/gzip 目录下找到的,源码:// Copyright 2010 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license tha

2017-11-23 19:31:01 636

原创 LeetCode 199. Binary Tree Right Side View

题目链接199. Binary Tree Right Side ViewGiven a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For exam

2017-11-21 20:08:38 113

原创 LeetCode 42. Trapping Rain Water

题目链接42. Trapping Rain WaterGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For exampl

2017-11-20 21:01:13 92

原创 LeetCode 131. Palindrome Partitioning--回溯法

题目链接131. Palindrome PartitioningGiven a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given

2017-11-08 13:29:55 270

原创 LeetCode 37. Sudoku Solver--回溯法

题目链接37. Sudoku SolverWrite a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one uni

2017-11-07 19:10:35 243

原创 回溯法解决八皇后问题

八皇后是一个古老而著名的问题,是回溯算法的典型案例。该问题是国际西洋棋棋手马克斯·贝瑟尔于1848年提出:在8×8格的国际象棋上摆放八个皇后,使其不能互相攻击,即任意两个皇后都不能处于同一行、同一列或同一斜线上,问有多少种摆法。 高斯认为有76种方案。1854年在柏林的象棋杂志上不同的作者发表了40种不同的解,后来有人用图论的方法解出92种结果。计算机发明后,有多种计算机语言可以解决此问题。

2017-11-07 15:05:25 232

原创 LeetCode 85. Maximal Rectangle&221. Maximal Square--动态规划

题目链接221. Maximal SquareGiven a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.For example, given the following matrix:1 0 1 0

2017-11-06 15:37:50 323

原创 LeetCode 279. Perfect Squares--动态规划

279. Perfect SquaresGiven a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 1

2017-11-05 16:43:36 249

原创 LeetCode 95. Unique Binary Search Trees II&96. Unique Binary Search Trees--动态规划,二叉树

题目链接96. Unique Binary Search TreesGiven n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's

2017-11-04 19:28:59 206

原创 GitHub协同开发fork

GitHub协同开发时,master建了一个仓库,然后其他人可以fork,这时可以在自己的账号创建一个副本,然后可以编辑自己的部分:为了方便在本地开发,可以使用GitHub Desktop,在本地修改仓库之后和自己的github同步:点开后就可以看到本地的项目,进行修改就可以了,就会显示出修改的文件,填了Summary和Descrption就可以提交到自己的仓库了

2017-10-25 15:34:23 393

原创 cobra安装

一.安装cobrago get -v github.com/spf13/cobra/cobra会报错,因为/src下缺少了golang.org文件夹,还有里面的sys,text文件夹,偷个懒,找了个现成的拖进去了这里下载然后就可以用啦,$GOPATH目录结构现在是这样的,有了cobra可执行文件:为项目实现一个register(注册用户)命令,register --

2017-10-24 21:49:25 1344

原创 LeetCode 316. Remove Duplicate Letters--贪心算法

题目链接316. Remove Duplicate LettersGiven a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result

2017-10-15 16:23:48 274

原创 Sicily 1000. 词法分析程序设计 **

Description设一语言的关键词、运算符、分界符的个数与单词如下: struct { int number; string str[10]; } keywords={3,"int","main","return"} ; //关键词struct { int number; string str[10]; } operators ={5,"+","*","=","+=","*="

2017-10-14 17:10:02 410

原创 安装 go 语言开发环境(ubuntu 16.04)

参考的是这一篇博客:博客地址1.大概等10几分钟就安装好了2.检测是否安装:结果:3.建立一个go的工作区文件夹,添加环境变量GOPATH4.写一个helloworld测试一下:// hello.gopackage mainimport ( "fmt" "os" "strings")

2017-10-11 18:59:20 2630

原创 安卓 使用Snackbar Failed to resolve: com.android.support:design:26.0.0 解决方案

使用Snackbar首先要在build.gradle app中添加库的依赖 compile 'com.android.support:design:26.+':注意

2017-10-10 20:39:17 4553 1

原创 LeetCode 135. Candy--贪心算法

题目链接135. CandyThere are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following requirements:Each

2017-09-29 15:04:45 316

原创 LeetCode 464. Can I Win--动态规划

题目链接464. Can I WinIn the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach or exceed 100 wins. W

2017-09-28 13:06:22 790

原创 动态规划经典入门级题目*2及详解

题目来自极客学院的视频教程-动态规划(一)一句话解释动态规划:多阶段最优化决策解决问题的过程解题技巧:只关注状态转移,不要考虑某个状态是怎么出现的1.字符串解码一个只包含大写字母的字符串加密后变成了只包含数字的字符串,加密的规则:'A' -> 1'B' -> 2...'Z' -> 26现在给定一个只包含数字的加密过的字符串,求该字符串有多少种解密的方法。例如“1

2017-09-25 19:29:47 1223

空空如也

空空如也

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

TA关注的人

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