自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 系统:win10 IDE:pycharm Python版本:2.7 安装第三方插件是报错: 这里写图片描述 报错原因与编码有关,pip把下载的临时文件存放在了用户临时文件中,这个目录一般是C

系统:win10 IDE:pycharm Python版本:2.7 安装第三方插件是报错:  报错原因与编码有关,pip把下载的临时文件存放在了用户临时文件中,这个目录一般是C:\Users\用户名\AppData\Local\Temp,目录名中有中文,显然ascii这种编码是不支持的,因为我的用户名是中文的所以出现了错误,解决方法: 找到python2.7目录下的Lib文

2017-12-01 16:04:48 794

转载 [python]解决Windows下安装第三方插件报错:UnicodeDecodeError: 'ascii' codec can't decode byte 0xcb in position 0:

系统:win10 IDE:pycharm Python版本:2.7 安装第三方插件是报错: 报错原因与编码有关,pip把下载的临时文件存放在了用户临时文件中,这个目录一般是C:\Users\用户名\AppData\Local\Temp,目录名中有中文,显然ascii这种编码是不支持的,因为我的用户名是中文的所以出现了错误,解决方法: 找到python2.7目录下的Lib文件夹

2017-02-09 11:49:58 1220

转载 安装第三方库出现 Python version 2.7 required, which was not found in the registry 建立一个文件 register.py 内容如下.

安装第三方库出现 Python version 2.7 required, which was not found in the registry建立一个文件 register.py 内容如下. 然后执行该脚本.import sysfrom _winreg import *# tweak as necessaryversion = sys.version[:3]installpath = sys

2016-12-30 17:05:12 1332

原创 mysql设置编码

MySQL 4.1的字符集支持(Character Set Support)有两个方面:字符集(Character set)和排序方式(Collation)。对于字符集的支持细化到四个层次: 服务器(server),数据库(database),数据表(table)和连接(connection)。 查看系统的字符集和排序方式的设定可以通过下面的两条命令或mysql> status 。 mysql>

2016-12-14 21:25:28 403

原创 Leetcode题解 396. Rotate Function

Given an array of integers A and let n to be its length.Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a “rotation function” F on A as follow:F(k) = 0 * Bk[

2016-10-08 15:30:38 411

原创 Leetcode题解 321. Create Maximum Number

Create Maximum Number 题目描述Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the

2016-08-28 22:35:01 710

原创 字符串消消乐

遇到3个一样的就标记 public static void test(String s) { boolean modify = false; int len = 0; char[] re = new char[s.length()]; for (int i = 0; i < s.length(); i++) {

2016-08-28 11:13:56 4330

原创 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.Note: The solution set must not contain duplic

2016-08-18 15:58:28 486

原创 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], [6,5,

2016-08-17 23:40:07 326

原创 Leetcode题解 122. Best Time to Buy and Sell Stock II

假设有一个数组,它的第i个元素是一个给定的股票在第i天的价格。设计一个算法来找到最大的利润。你可以完成尽可能多的交易(多次买卖股票)。然而,你不能同时参与多个交易(你必须在再次购买前出售股票)。 解题思路 在Best Time to Buy and Sell Stock系列中,和本题最像的是Best Time to Buy and Sell Stock IV Best Time to Buy

2016-08-17 09:45:40 920 2

原创 Android中使用Handler造成内存泄露的分析和解决

什么是内存泄露? Java使用有向图机制,通过GC自动检查内存中的对象(什么时候检查由虚拟机决定),如果GC发现一个或一组对象为不可到达状态,则将该对象从内存中回收。也就是说,一个对象不被任何引用所指向,则该对象会在被GC发现的时候被回收;另外,如果一组对象中只包含互相的引用,而没有来自它们外部的引用(例如有两个对象A和B互相持有引用,但没有任何外部对象持有指向A或B的引用),这仍然属于不可到达,

2016-08-16 23:45:14 317

原创 Leetcode题解 219. Contains Duplicate II

Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.用hashMap

2016-08-16 00:05:44 738

原创 Leetcode题解 136. Single Number

Given an array of integers, every element appears twice except for one. Find that single one.第一种解法就是《剑指offer》上的,下面是一种通用的解法:public class Solution { public static int singleNumber(int[] nums) {

2016-08-11 10:53:40 288

原创 Leetcode题解 343. Integer Break

Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2, return 1

2016-07-20 18:06:37 306

原创 Leetcode题解 347. Top K Frequent Elements

Given a non-empty array of integers, return the k most frequent elements.For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].用桶排序来做最后处理。public class Solution { public List<Integer> topKFreque

2016-07-20 16:03:51 342

原创 Leetcode题解 268. Missing Number

Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example, Given nums = [0, 1, 3] return 2.解法一:(用等差数列的做法)public class Solution {

2016-07-20 16:02:46 383

原创 Leetcode题解 142. Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.《程序员面试金典》原题/** * Definition for singly-linked list. * class ListNode { * int val; * ListNode n

2016-07-19 22:23:22 351

原创 Leetcode题解 141. Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?解法一:不用任何额外空间去做。/** * Definition for singly-linked list. * class ListNode { * int val

2016-07-19 22:21:50 307

原创 Leetcode题解 287. Find the Duplicate Number

Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, fin

2016-07-19 22:11:28 384

原创 Leetcode题解 28. Implement strStr()

Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.解法一:(暴力法)public class Solution { public static int strStr(String haystack

2016-07-18 12:09:21 417

原创 Leetcode题解 204. Count Primes

Description:Count the number of prime numbers less than a non-negative number, n.厄拉多塞筛法public class Solution { public int countPrimes(int n) { int[] res=new int[n]; int count=0;

2016-07-18 11:34:33 362

原创 Leetcode题解 165. Compare Version Numbers

Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and conta

2016-07-17 11:49:25 248

原创 Leetcode题解 278. First Bad Version

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the

2016-07-17 00:12:44 438

原创 Leetcode题解 303. Range Sum Query - Immutable

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRange(0, 5) ->

2016-07-16 23:56:21 363

原创 Leetcode题解 374. Guess Number Higher or Lower

We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to gue-1 : My number is lower 1 : My number is higher 0 : Congrats! You got it!Example:n = 10, I pick 6.R

2016-07-16 23:33:24 1014

原创 Leetcode题解 168. Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB public class Solut

2016-07-16 23:09:06 365

原创 Leetcode题解 238. Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(n).For e

2016-07-16 22:28:34 300

原创 Leetcode题解 119. Pascal's Triangle II

Given an index k, return the kth row of the Pascal’s triangle.For example, given k = 3, Return [1,3,3,1].public class Solution { public List<Integer> getRow(int rowIndex) { List<List<Inte

2016-07-16 11:09:28 274

原创 Leetcode题解 107. Binary Tree Level Order Traversal II

Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).For example: Given binary tree [3,9,20,null,null,15,7],

2016-07-16 11:00:21 223

原创 Leetcode题解 102. Binary Tree Level Order Traversal

Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 /

2016-07-16 10:58:55 269

原创 Leetcode题解 118. Pascal's Triangle

Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]public class Solution { public Li

2016-07-16 10:57:57 323

原创 Leetcode题解 160. Intersection of Two Linked Lists

Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘ c1

2016-07-14 22:35:32 267

原创 Leetcode题解 189. Rotate Array

Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].注意代码中的这句话: k=k%len; 也就是说,当k比数组长度还要大时,就需要对k取余。public cla

2016-07-14 22:16:18 272

原创 Leetcode题解 24. Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head.For example, Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You may no

2016-07-14 22:02:39 253

原创 Leetcode题解 190. Reverse Bits

Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110

2016-07-14 21:27:46 340

原创 Leetcode题解 19. Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked list be

2016-07-14 21:26:53 239

原创 Leetcode题解 371. Sum of Two Integers

Calculate 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. 用位运算来做public class Solution { public int getSum(int a, int

2016-07-14 17:35:31 366

原创 疯狂java讲义 琐碎知识点

Java的子类不能获得父类的构造器,但在子类构造器中可以调用父类构造器的初始化代码。严格讲,Java类只能有一个父类,这种说法是错误的,应该换成如下说法:Java类只能有一个直接父类。实际上,Java可以有无限多个间接父类。如果在构造器中使用super,则super用于限定该构造器初始化的是该对象从父类继承得到的实例变量,而不是该类自己定义的实例变量。在继承中,实例变量也会发生类似于函数覆盖的

2016-07-14 17:34:24 757

原创 用java语言实现事件委托模式

http://blog.csdn.net/yanshujun/article/details/6494447

2016-07-11 13:15:44 469

原创 程序员面试金典题解 有向路径检查

题目描述对于一个有向图,请实现一个算法,找出两点之间是否存在一条路径。 给定图中的两个结点的指针UndirectedGraphNode* a,UndirectedGraphNode* b(请不要在意数据类型,图是有向图),请返回一个bool,代表两点之间是否存在一条路径(a到b或b到a)。import java.util.*;/*public class UndirectedGraphNode

2016-07-10 18:22:30 357

空空如也

空空如也

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

TA关注的人

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