自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(35)
  • 问答 (1)
  • 收藏
  • 关注

转载 快速理解数字签名(digital signature)和证书中心(certificate authority)

Bob(Bob's public key)(Bob's private key)

2017-10-18 15:54:12 2458

原创 [Leetcode] 47. Permutations II

Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[ [1,1,2], [1,2,1], [2,1,1

2017-09-29 20:57:16 260

转载 [Leetcode] 576. Out of Boundary Paths

原方法参见博文:http://www.cnblogs.com/grandyang/p/6927921.htmlhere is an m by n grid with a ball. Given the start coordinate (i,j) of the ball, you can move the ball to adjacent cell or cross the grid bo

2017-09-03 18:16:55 377

原创 [Leetcode] 646. Maximum Length of Pair Chain

You are given n pairs of numbers. In every pair, the first number is always smaller than the second number.Now, we define a pair (c, d) can follow another pair (a, b) if and only if b . Chain

2017-09-03 00:11:05 476

原创 [Leetcode] 44. Wildcard Matching

Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cov

2017-08-27 16:02:28 223

原创 [Leetcode] 12. Integer to Roman

Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.因为罗马计数对于每一位数字计数规则都是一样的,所以我们可以给个、十、百、千位都打一张罗马计数表,然后把输入的数字按位逐次表示出来,就OKAY了,非常简单机械的方法。但是由

2017-08-24 21:51:03 257

原创 [Leetcode] 403. Frog Jump

A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.Given a list of

2017-08-12 23:36:21 332

原创 Python中的堆数据结构——heap模块

>>> import heapq>>> help(heapq)Help on module heapq:NAME heapq - Heap queue algorithm (a.k.a. priority queue).FILE c:\python27\lib\heapq.pyDESCRIPTION Heaps are arrays for which a[

2017-08-08 20:50:06 1849

原创 [Leetcode] 39. Combination Sum

Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen

2017-08-01 14:59:03 232

原创 [Leetcode] 3. Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "

2017-07-17 22:19:45 205

原创 [Leetcode] 32. Longest Valid Parentheses

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",

2017-07-17 17:11:11 169

原创 [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.合并两个有序链表,只允许通过两个链表相互插接的方式自己写怎么也写不出,后来才知道用递归做,既简洁又高效率。

2017-07-17 10:39:26 222

原创 [Leetcode] 617. Merge Two Binary Trees

Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new binary tr

2017-07-14 14:53:57 881

原创 利用python编程实现两excel表格的快速信息融合(xls文件的读和写)

今天有朋友问我一个EXCEL的问题,她拿到了两个表,现在需要对表的内容进行融合,如下图所示:图一所示的表格给出了相应字段的信息,图二就是需要填写的表格。问题是,图二中存在单元格合并的问题,并且每一个人的信息后面还跟着一行“小计”,所以简单的excel复制粘贴不管用了。尝试使用excel中的vlookup函数,也不管用。总之就是这个合并单元格的问题很麻烦。而图一中的信息有几千

2017-06-27 20:52:36 4258 1

原创 [Leetcode] 135. Candy

题目:There 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 child must have at

2017-05-12 21:19:41 170

原创 [Leetcode] 11. Container With Most Water

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin

2017-05-12 15:22:27 191

原创 [Leetcode] 15. 3Sum

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.无限超时。。。最后用这个O(n2)复杂度class Sol

2017-04-15 23:23:01 203

原创 [Leetcode] 42. Trapping Rain Water

好巧妙,双指针法,找到顶峰,左边开始数到最大,再从右边开始数到最大。class Solution(object): def trap(self, height): """ :type height: List[int] :rtype: int """ if len(height)<=2:

2017-04-15 18:57:24 199

原创 USACO 2.3 Zero Sum

题目:Zero SumConsider the sequence of digits from 1 through N (where N=9) in increasing order: 1 2 3 ... N.Now insert either a `+' for addition or a `-' for subtraction or a ` ' [blank] to r

2017-04-15 16:24:38 374

转载 Python模块: collections学习

转载自:http://www.zlovezl.cn/articles/collections-in-python/阅读官方文档和模块源码:https://docs.python.org/2/library/collections.html#module-collections基本介绍我们都知道,Python拥有一些内置的数据类型,比如str, int, list,

2017-04-15 10:47:36 315

原创 Python中用list创建二维数组的方法

b =[[1 for x in range(n)] for y in range(m)]上面一句就初始化了一个m*n的二维数组,且初始值全为1

2017-04-13 13:57:06 11130

原创 使用结巴分词后程序打包失败

做毕设时又碰到了一个难题,使用结巴分词和analyse后没法正常打包程序。使用py2exe得不到.exe文件,使用PyInstaller程序报错。报错信息如下(图片来自文献1):后来参考了文献1和文献2后知道原来是因为import jieba需要用到dict.txt,而打包后的程序找不到dict.txt的路径了。解决方法如下:在你的代码中写如下三句:import jie

2017-04-08 17:02:32 3852 13

原创 USACO 2.2 Runaround Numbers

题目:Runaround numbers are integers with unique digits, none of which is zero (e.g., 81362) that also have an interesting property, exemplified by this demonstration:If you start at the left dig

2017-04-06 11:33:45 258

原创 USACO 2.2 Party Lamps

题目:To brighten up the gala dinner of the IOI'98 we have a set of N (10 N.The lamps are connected to four buttons:Button 1: When this button is pressed, all the lamps change their state: those

2017-04-05 15:52:42 277

转载 python中matplotlib的颜色及线条控制

这篇文章太棒啦,下次用python画图的时候选色选点都可以直接参考这边,牛逼!原文章链接:http://www.cnblogs.com/darkknightzh/p/6117528.html参考网址:http://stackoverflow.com/questions/22408237/named-colors-in-matplotlibhttp://s

2017-03-28 15:07:13 31501

原创 Python中实现map+链表功能的方法

今天在做毕设的时候碰到一个问题:需要一种数据结构实现以下的这种结构(图片来自网络):其实就是将n个元素按照某种规则进行hash,并挂在对应的key下面(key的范围是从0到2^22)我第一反应就是使用python中的dict,结构为 {key:[]}。但是简单的用如下的语句,很显然会报错KeyError:t = dict()t[0].append()原因是现在我们

2017-03-26 22:40:00 818

原创 USACO 2.2 Preface Numbering

A certain book's prefaces are numbered in upper case Roman numerals. Traditional Roman numeral values use a single letter to represent a certain subset of decimal numbers. Here is the standard set:

2017-03-02 15:08:50 262

转载 TF-IDF及其算法

原文请见http://www.cnblogs.com/biyeymyhjob/archive/2012/07/17/2595249.html概念     TF-IDF(term frequency–inverse document frequency)是一种用于资讯检索与资讯探勘的常用加权技术。TF-IDF是一种统计方法,用以评估一字词对于一个文件集或一个语料库中的其中一份文件的重

2017-02-28 10:19:39 317

转载 深入理解Java中的final关键字

Java中的final关键字非常重要,它可以应用于类、方法以及变量。这篇文章中我将带你看看什么是final关键字?将变量,方法和类声明为final代表了什么?使用final的好处是什么?最后也有一些使用final关键字的实例。final经常和static一起使用来声明常量,你也会看到final是如何改善应用性能的。final关键字的含义?final在Java中是一个保留的关键字,可

2016-11-08 21:14:31 203

原创 USACO 2.2 Subset Sums

Subset SumsJRMFor many sets of consecutive integers from 1 through N (1 For example, if N=3, one can partition the set {1, 2, 3} in one way so that the sums of both subsets are identical:{3}

2016-11-01 16:51:51 283

原创 USACO 2.1 The Castle

In a stroke of luck almost beyond imagination, Farmer John was sent a ticket to the Irish Sweepstakes (really a lottery) for his birthday. This ticket turned out to have only the winning number for th

2016-10-21 12:18:22 305

原创 USACO 2.1 Hamming Codes

Given N, B, and D: Find a set of N codewords (1 <= N <= 64), each of length B bits (1 <= B <= 8), such that each of the codewords is at least Hamming distance of D (1 <= D <= 7) away from each of the

2016-10-20 16:37:17 282

原创 USACO 2.1 Healthy Holsteins

Farmer John prides himself on having the healthiest dairy cows in the world. He knows the vitamin content for one scoop of each feed type and the minimum daily vitamin requirement for the cows. Help F

2016-10-20 15:05:13 361

原创 开始写博客

说起来也惭愧,已经是条大四狗了,但是还是C渣渣,编程的小白。和我的其他同学比起来,自己的编程能力一直没有很大的提高。当然这和我自身的不努力有很大关系,大学里有好多次想下定决心刷OJ,但尝试了好多个OJ平台,都没能坚持地下去。题目难就不想做,加上平时也蛮忙碌的,然后渐渐的就放弃了。 去年年底的时候想开始刷USACO,听同学说是分章节的,比较系统性,而且前面的题目也算比较简单的,于是就开始了usaco

2016-10-20 12:13:07 293 2

原创 USACO 2.1 Sorting a Three-Valued Sequence

题目:Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted have at most threedifferent key values. This happens

2016-10-19 18:23:51 307

空空如也

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

TA关注的人

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