- 博客(32)
- 资源 (7)
- 收藏
- 关注
原创 JAVA菜鸟入门(12) reference variable是气球的线 +JVM中怎么实现
1 如果variable是primitive,那就拷贝原来变量的值到新变量。2 如果variable是object referece, 那就拷贝原来reference的值到新的变量,所以就有2个reference varibal指向了相同的object.eg. // Before the method callObject x = null;// Start of method c
2015-04-28 23:42:42 4665
原创 JAVA菜鸟入门(11) 基本类型
一. 基本类型Java 基础数据类型byte (number, 1 byte)short (number, 2 bytes)int (number, 4 bytes)long (number, 8 bytes)float (float number, 4 bytes)double (float number, 8 bytes)char (a characte
2015-04-26 01:11:03 1130
原创 JAVA菜鸟入门(10) 类初始化, 字符串比较equals() v.s. ==, Casting, ArrayList注意
一. 类的初始化第一种更推荐, 可以简化或者省略构造函数,代码简洁第二种 public class WeatherForecast{private String skies = "";private int high = 0;private int low = 0;public void setSkies(
2015-04-26 00:50:09 841
原创 JAVA菜鸟入门(9) Java打印一维数组,二维数组
一 打印list中的元素0 JAVA风格的最简做法import java.util.List;...List l = new ArrayList(3);System.out.println(l);1 JAVA风格的做法import java.util.Arrays;import java.util.List;import java.util.ArrayList;...
2015-04-26 00:39:24 15959 1
原创 JAVA菜鸟入门(8) Java的Final关键字
java final 和C++的const功能类似,用来表达常量,还能用在class或者method上,提供不同的用法。1. Java Final Variable Once a final variable has been assigned, it always contains the same value.但是 static final和private final是
2015-04-26 00:32:37 1230
原创 LeetCode(119) Pascal's Triangle II (Java)
题目如下:Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?我的代码:
2015-04-20 10:01:28 2590
原创 LeetCode(188) Best Time to Buy and Sell Stock IV (Java)
题目如下:Best Time to Buy and Sell Stock Total Accepted: 43912 Total Submissions: 135635 My Submissions Question Solution Say you have an array for which the ith element is the price of a given stock
2015-04-19 15:45:27 7382
原创 LeetCode(123) Best Time to Buy and Sell Stock III (Java)
题目如下:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:Y
2015-04-19 13:20:26 1521
原创 LeetCode(122) Best Time to Buy and Sell Stock II (Java)
题目如下:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie,
2015-04-19 13:18:34 1532
原创 LeetCode(121) Best Time to Buy and Sell Stock (Java)
题目如下:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the
2015-04-19 13:15:43 1785
原创 LeetCode(045) Jump Game II (Java)
题目如下:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your
2015-04-13 15:00:17 1318
原创 LeetCode(055) Jump Game (Java)
题目如下:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Dete
2015-04-13 13:43:48 571
原创 LeetCode(080) Remove Duplicates from Sorted Array II (Java)
题目如下:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should return length = 5, and A is now
2015-04-13 13:18:27 542
原创 LeetCode(074) Search a 2D Matrix (Java)
题目如下:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of
2015-04-13 12:37:58 1171
原创 LeetCode(034) Search For a Range (Java)
题目如下:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not
2015-04-13 10:44:31 1054
原创 LeetCode(048) Rotate Image
题目如下:You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?分析如下:首先沿着对角线(左上->右下)方向翻折,然后沿着中轴方向翻折。
2015-04-13 04:06:41 494
原创 LeetCode(035) Search Insert Position (Java)
题目如下:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the
2015-04-13 01:57:35 613
原创 LeetCode(073) Set Matrix Zeroes (Java)
题目如下:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.Follow up:Did you use extra space?A straight forward solution using O(mn) space is probably
2015-04-13 01:26:49 667
原创 LeetCode(118) Pascal's Triangle (Java)
题目如下: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]]我的代码:
2015-04-12 15:48:08 1760
原创 LeetCode(088) Merge Sorted Array(Java)
题目如下:Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional element
2015-04-12 14:25:10 726
原创 LeetCode(001) Two Sum (Java)
题目如下:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the targ
2015-04-12 07:12:48 731
原创 LeetCode(026) Remove Duplicates from Sorted Array (Java)
题目如下:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in pla
2015-04-12 03:13:57 680
原创 LeetCode(169) Majority Element (Java)
题目如下:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority ele
2015-04-12 02:53:32 1571
原创 LeetCode(027) Remove Element (Java)
题目如下:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new lengt
2015-04-12 02:36:03 3777
原创 LeetCode(066) Plus One (Java)
题目如下:Plus One Total Accepted: 42505 Total Submissions: 138460 My Submissions Question Solution Given a non-negative number represented as an array of digits, plus one to the number.The digits
2015-04-12 01:21:30 1147
原创 LeetCode(189) Rotate Array(Java)
题目如下:Rotate Array Total Accepted: 19161 Total Submissions: 108570 My Submissions Question Solution Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the
2015-04-12 00:15:30 2749
原创 JAVA菜鸟入门(7) default parameter , float/double vs BigDecimal
1 java不支持类似C++那样,为函数设定默认参数,所以需要做的事情是,自己用函数重载的方式进行模拟。如下public class FFOverload { public String getName(String givenName,String familyName){ return givenName+"."+familyName; } public String getNa
2015-04-11 01:11:58 1124
原创 LeetCode(140) Word Break II
题目如下:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, given
2015-04-10 08:12:30 3443
原创 JAVA菜鸟入门(6) java中的reference 和 C++中的pointer的区别
首先说明,这里比较的是java中的reference和c++中的pointer,不是java中的reference和c++中的reference,因为这后二者差别非常明显。Referencesmight be implemented by storing the address. Usually Java references will be implemented
2015-04-09 13:34:39 3329
转载 (zz) 趣题:用最少的“并行交换”完成排序(by matrix67 )
source: http://www.matrix67.com/blog/archives/954 因为matrix67大牛的这个题目非常有趣,所以就转载了. 曾经有一段时间这个Blog的访问量和订阅量剧增,后来才知道因为这个Blog上的一道牛B题目被出成POJ的月赛题了。那道题目真的很好玩,题目和解答都很简单有趣。其实我挺喜欢这种“给出一个算法并证明该算法最优”类
2015-04-08 02:50:51 1391
原创 LeetCode(198) Horse Robber
题目如下:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacen
2015-04-08 01:02:38 653
原创 LeetCode(126) Word Ladder II
题目如下:Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can be changed at a timeEach intermediate word
2015-04-07 01:26:19 2883
数据挖掘--概念.模型.方法和算法
2009-09-20
机器学习 Tom Mitchell 中文版
2009-09-20
机器学习英文版Machine Learning(Mitchell)(下)
2009-09-14
机器学习英文版Machine Learning(Mitchell)(中)
2009-09-14
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人