随笔分类 -  Java

摘要:我用的是oh my zsh,需要修改.zshrc,记一下免得以后忘记在哪儿改的。 如果你用的是自带的terminal那么用文本编辑器打开用户目录下的.bash_profile文件 在.bash_profile文件中加入: 其中 /path/to/jdk就是你的jdk安装路径。 阅读全文
posted @ 2016-12-02 14:36 丶Blank 阅读(941) 评论(0) 推荐(0)
摘要:不知道为什么,现在某些公司喜欢考单链表快排,有什么意思呢?没意思。首先理解快排的思想,partition,递归。代码里有注释,挺详细的了,自己验证逻辑应该没什么问题。package leetcode.sort;import java.io.FileInputStream;import java.io... 阅读全文
posted @ 2015-11-04 13:20 丶Blank 阅读(1358) 评论(0) 推荐(0)
摘要:package leetcode.sort;import java.util.Arrays;/** * QuickSort * Created by blank on 2015-09-22 下午12:06. */public class QuickSort { static int[] arr... 阅读全文
posted @ 2015-09-22 12:13 丶Blank 阅读(185) 评论(0) 推荐(0)
摘要:package leetcode.sort;import java.util.Arrays;import java.util.Random;/** * HeapSort * Created by blank on 15/8/12. */public class HeapSort { publi... 阅读全文
posted @ 2015-09-22 12:05 丶Blank 阅读(144) 评论(0) 推荐(0)
摘要:package leetcode.sort;import java.util.Arrays;import java.util.Random;/** * Created by blank on 2015-09-22 上午11:42. */public class MergeSort { publ... 阅读全文
posted @ 2015-09-22 12:04 丶Blank 阅读(190) 评论(0) 推荐(0)
摘要:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ... 阅读全文
posted @ 2015-06-30 14:14 丶Blank 阅读(193) 评论(0) 推荐(0)
摘要:Given an array of integers, find out whether there are two distinct indicesiandjin the array such that the difference betweennums[i]andnums[j]is at mo... 阅读全文
posted @ 2015-06-25 15:20 丶Blank 阅读(141) 评论(0) 推荐(0)
摘要:Sort a linked list inO(nlogn) time using constant space complexity.链表排序,要求时间复杂度O(nlgn),我写的归并排序。/** * Definition for singly-linked list. * public class... 阅读全文
posted @ 2015-06-07 16:52 丶Blank 阅读(141) 评论(0) 推荐(0)
摘要:Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文
posted @ 2015-05-05 22:58 丶Blank 阅读(124) 评论(0) 推荐(0)
摘要:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C prog... 阅读全文
posted @ 2015-05-05 22:52 丶Blank 阅读(199) 评论(0) 推荐(0)
摘要:Given a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9], the largest formed num... 阅读全文
posted @ 2015-04-20 19:36 丶Blank 阅读(185) 评论(0) 推荐(0)
摘要:写了个抓取appstore的,要抓取大量的app,本来是用httpclient,但是效果不理想,于是直接调用wget下载,但是由于标准输出、错误输出的原因会导致卡住,另外wget也会莫名的卡住。所以我采用:一、独立线程读取输出信息;二、自己实现doWaitFor方法来代替api提供的waitFor(... 阅读全文
posted @ 2015-01-28 17:27 丶Blank 阅读(1993) 评论(0) 推荐(0)
摘要:SVN项目库错误Unsupported FS format svn: Expected FS format between '1' and '4'; found format '6'从这里找到解决方案 http://stackoverflow.com/a/18382077原因是用 >=1.8版本的S... 阅读全文
posted @ 2014-08-13 16:00 丶Blank 阅读(7006) 评论(0) 推荐(0)
摘要:Java中的transient,是用于声明序列化的时候不被存储的。例子:package ThreadTest;/** * Created with IntelliJ IDEA. * User: Blank * Date: 14-3-29 * Time: 下午12:03 */import java.io.*;import java.util.*;class Logon implements Serializable { private Date date = new Date(); private String username; private transient Strin... 阅读全文
posted @ 2014-03-29 12:14 丶Blank 阅读(1643) 评论(0) 推荐(0)
摘要:thread.Join把指定的线程加入到当前线程,可以将两个交替执行的线程合并为顺序执行的线程。比如在线程B中调用了线程A的Join()方法,直到线程A执行完毕后,才会继续执行线程B。t.join(); //调用join方法,等待线程t执行完毕t.join(1000); //等待 t 线程,等待时间是1000毫秒。下面是一段JDK中的代码: /** * Waits at most millis milliseconds for this thread to * die. A timeout of 0 means to wait forever. */... 阅读全文
posted @ 2014-03-28 20:58 丶Blank 阅读(75364) 评论(7) 推荐(3)
摘要:实验题目 回溯法实现8皇后问题实验要求 a.掌握递归回溯算法的基本思想。 b.学习掌握应用面向对象通用回溯程序框架解决实际问题。 提高面向对象编程的技能。作业描述:在8*8格的棋盘上放置彼此不受攻击的8个皇后。按照国际象棋的规则,皇后可以攻击与之处在同一行或同一列或同一斜线上的棋子。8后问题等价于在n*n格的棋盘上放置8个皇后,任何2个皇后不放在同一行或同一列或同一斜线上。package pku.java;import java.util.ArrayList;import java.util.List;public class Main { private static int SIZE... 阅读全文
posted @ 2013-09-20 23:30 丶Blank 阅读(1001) 评论(0) 推荐(0)
摘要:POJ-Prob.1458 看算法导论3 自己用java写的,flag可以不用,课后题要求用min(m,n)+O(1)的空间完成...改天再写. 1 import java.util.Scanner; 2 3 /** 4 * Created by IntelliJ IDEA. 5 * User: mayday 6 * Date: 13-2-15 7 * Time: 下午5:03 8 */ 9 public class Main {10 public static int m, n;11 12 public static void main(String[] args... 阅读全文
posted @ 2013-02-15 18:46 丶Blank 阅读(317) 评论(1) 推荐(0)
摘要:Inobject-orientedandfunctionalprogramming, animmutable objectis anobjectwhose state cannot be modified after it is created.[1]This is in contrast to amutable object, which can be modified after it is created.Immutable objects are often useful because they are inherentlythread-safe.[1]Other benefits 阅读全文
posted @ 2012-04-08 14:09 丶Blank 阅读(366) 评论(0) 推荐(0)