自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(145)
  • 资源 (5)
  • 收藏
  • 关注

原创 论volatile

今天和同学讨论java关键字volatile时,他说volatile是同步的,安全的,我说不是,于是我写了如下代码来论证不是同步的,public class Counter { public volatile static int count = 0; public static void inc() { // 这里延迟1毫秒,使得结果明显 try { Thread.slee

2015-09-10 10:31:25 505

转载 .gitignore

原文链接: http://www.javaranger.com/archives/1227 .gitignore有两种文件过滤模式,开放模式和保守模式1.开放模式是设置哪些文件和文件夹要被过滤,例如:帮助1/target/ 表示过滤这个文件夹2.保守模式是设置哪些

2015-05-05 15:43:56 419

原创 LeetCode 76 Minimum Window Substring

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BANC".

2014-11-26 15:33:58 635

原创 LeetCode 41 Trapping Rain Water

Given 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 example, Given [0,1,0,2,1,0,1,3,2,1,2,1],

2014-11-25 16:28:51 638

原创 LeetCode 43 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 cover t

2014-11-24 18:46:20 735

原创 LeetCode 87 Scramble String

Given 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 = "great": great / \ gr

2014-11-22 19:43:06 645

原创 LeetCode 39 Combination Sum II

Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combinati

2014-11-16 22:31:57 376

原创 LeetCode 38 Combination Sum

Given a set of candidate numbers (C) 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 from C unlimited number

2014-11-16 22:28:23 469

原创 LeetCode 115 Distinct Subsequences

Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be none)

2014-11-14 11:00:45 783

原创 LeetCode 71 Simplify Path

Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"Corner Cases:Did you consider the case where path = "/

2014-11-13 16:10:50 787

原创 LeetCode 42 Multiply Strings

Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.这道题其实是到

2014-11-12 19:13:40 408

原创 LeetCode 48 Anagrams

Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.他的意思就是回文构词法,即单词里的字母的种类和数目没有改变,只是改变了字母的排列顺序。input= ["abc", "

2014-11-12 15:07:23 604

原创 LeetCode 124 Binary Tree Maximum Path Sum

Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return 6.

2014-11-12 13:17:52 735

原创 LeetCode 51 N-Queens II

Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.思路1:打表public class Solution { public int totalNQ

2014-11-10 18:27:42 591

原创 LeetCode 50 N-Queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.E

2014-11-10 18:22:17 945

转载 如何用随机函数rand5来构造随机函数rand7

试一下以对话的方式写博~如果看不到人物头像,请刷新页面获取最新的CSS。如果有建议或意见,欢迎到我的微博上跟帖~ 这里是腾讯微博,这里是新浪微博。常规方法今天公司有一个面试题是这样的:假如有一个函数rand5能等概率生成1 - 5 之间的整数,如何利用rand5来实现rand7?rand7函数的要求是能够等概率生成1 - 7之间的整数。说实话我自己也不是很清楚。

2014-11-10 15:20:15 572

原创 java 数组与容器赋值与输出问题

数组的复制可以采用yijia

2014-11-08 23:39:26 700

原创 LeetCode 72 Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:

2014-11-08 22:39:56 894

原创 Java大数类介绍

java能处理大数的类有两个高精度大整数BigInteger 和高精度浮点数BigDecimal,这两个类位于java.math包内,要使用它们必须在类前面引用该包:import java.math.BigInteger;和import java.math.BigDecimal;或者import java.math.*;下面从几个方面对BigInteger和BigDecima做一个

2014-11-03 16:34:54 1017

原创 atcoder 之February 29th

Time limit : 2sec / Stack limit : 256MB / Memory limit : 256MBProblemCharlie was born January 1st of the year A, on the Earth. He will leave the Earth on December 31st of the year B.He w

2014-11-02 16:14:42 1182

原创 atcoder之A Great Alchemist

C - A Great AlchemistTime limit : 2sec / Stack limit : 256MB / Memory limit : 256MBProblemCarol is a great alchemist.In her world, each metal has a name of 2N (N is an integer) l

2014-11-02 16:03:54 1212

原创 atcoder之A Mountaineer

Time limit : 2sec / Stack limit : 256MB / Memory limit : 256MBProblemDave is a mountaineer. He is now climbing a range of mountains.On this mountains, there are N huts located on a strai

2014-11-02 11:39:02 1336

原创 LeetCode 36 Sudoku Solver

Write 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 unique solution.A sudoku puzzle.

2014-11-01 21:00:04 716

原创 java 集合交并补

通过使用泛型方法和Set来表达数学中的表达式:集合的交并补,在以下三个方法中豆浆第一个参数Set复制了一份,并未直接修改参数中Set。package Set;import java.util.HashSet;import java.util.Set;public class Sets { public static Set intersection(Set s1, Set s2)

2014-10-31 16:55:26 2733

原创 LeetCode 117 Populating Next Right Pointers in Each Node II

Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant extr

2014-10-31 10:05:28 893

原创 LeetCode 96 Unique Binary Search Trees II

Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3

2014-10-30 20:41:24 542

原创 LeetCode 5 Longest Palindromic Substring

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.思路1:

2014-10-30 19:56:33 649

原创 LeetCode 131 Palindrome Partitioning

Given 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 s = "aab",Return [ ["aa","b"],

2014-10-27 15:07:00 652

原创 LeetCode 132 Palindrome Partitioning II

Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab",Return 1 s

2014-10-24 17:57:46 749

原创 LeetCode 58 Spiral Matrix II

Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [

2014-10-23 11:01:57 524

原创 LeetCode 53 Spiral Matrix

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You

2014-10-23 10:56:00 519

原创 LeetCode 146 LRU Cache

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if

2014-10-22 11:52:30 606

原创 LeetCode 148 Sort List

Sort a linked list in O(n log n) time using constant space complexity.思路:要想时间复杂度达到O(n log n) ,那么有两种,一种是合并排序,另一种是快速排序,而要想空间复杂度为常数,那么只能使用递归,本人使用的是递归的合并排序,代码如下:/** * Definition for s

2014-10-22 11:44:26 522

原创 LeetCode 154 Find Minimum in Rotated Sorted Array II

Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose a sorted array is rotated at some pivot unkno

2014-10-22 11:32:14 1412

原创 LeetCode 153 Find Minimum in Rotated Sorted Array

Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exists in the ar

2014-10-22 11:24:12 739

原创 LeetCode 97 Interleaving String

Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", retur

2014-10-09 13:17:12 1288

原创 LeetCode 68 Text Justification

Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.You should pack your words in a greedy approach; that is,

2014-09-17 14:07:16 1078

原创 LeetCode 29 Substring with Concatenation of All Words

You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without an

2014-09-15 13:34:58 727

原创 LeetCode 6 ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I

2014-09-13 21:52:02 701

原创 LeetCode 17 4Sum

Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Elements

2014-09-09 19:30:14 699

c语言中常见的错误

这是c语言中常见的错误,由编译器所提供以及自我分析

2013-04-19

C++库函数电子书

这本电子书是c++库函数,对我们c++变成十分有用,值得你下载!

2013-04-19

电子科大java实验

该实验的代码由本人亲写,代码无任何问题,其中有代码还有优化

2011-05-18

数据结构主要算法动画演示

这是我们在学习数据结构时所常用的算法,对以后的编程,有用。所采用的是swf格式,请用flash打开。

2010-06-02

你必须知道的495个C语言问题

这是我们在学习c语言过程中必须知道的c语言问题!

2010-05-27

空空如也

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

TA关注的人

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