自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(30)
  • 资源 (1)
  • 收藏
  • 关注

原创 12/22 学习笔记 IO 和一些regex的知识

1 关于File关键点File doesn't really mean a file, it means "FilePath". It can represent either the name of a particular file or the names of a set of files in a directory. 用list 来返回一个当前path下面的所有的文件还有文件夹的名

2015-12-23 06:32:12 299

原创 12/21 学习笔记 hashcode String

1.看了有关immutable class的资料, An object is considered immutable if its state cannot change after it is constructed. Maximum reliance on immutable objects is widely accepted as a sound strategy for creat

2015-12-22 06:07:23 351

原创 看了thinking in java 的initialize and cleanup 的一点总结

今天看了java的initialization的一章, 感觉又学到了一点心得东西

2015-12-20 00:41:36 480

原创 leetcode-set Matrix Zero

Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.public class Solution { public void setZeroes(int[][] matrix) { int[] row=new int[matrix.le

2015-02-19 10:23:53 349

原创 leetcode-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,public class Solution { int result=Integer.M

2015-01-28 09:33:16 343

原创 leetcode-unique binary search tree 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.public class

2015-01-28 07:20:44 296

原创 leetcode-valid binary search tree

Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.Th

2015-01-28 03:57:00 272

转载 java 中String 常用

Charsequence最近在学习Android但是在学习过程中发现CharSequence这个数据类型,自己真的是不了解,在上网找了找,原来这是一个接口:在JDK1.4中,引入了CharSequence接口,实现了这个接口的类有:CharBuffer、String、StringBuffer、StringBuilder这个四个类。 CharBuffer为nio里面用的一个类,Strin

2015-01-25 09:38:27 286

原创 leetcode-count and say

The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as 

2015-01-21 08:24:33 317

原创 leetcode-min stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get

2015-01-20 11:51:04 248

原创 leetcode-first missing element

Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant

2015-01-20 11:10:17 381

原创 leetcode-two sum

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 target, whe

2015-01-20 00:51:36 246

原创 leetcode-anagrams

Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.public class Solution { public List anagrams(String[] strs) { HashM

2015-01-19 12:08:09 327

原创 leetcode-valid parenthesses

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va

2015-01-18 09:40:08 320

原创 leetcode-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

2015-01-18 08:58:46 271

原创 leetcode-find peak number

A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, i

2015-01-11 02:43:38 481

原创 leetcode-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:

2015-01-10 05:44:38 296

原创 leetcode-climbing stairs

Climbing Stairs Total Accepted: 36520 Total Submissions: 107274My SubmissionsQuestion Solution You are climbing a stair case. It takes n steps to reach to the top.Each time you

2015-01-10 05:14:02 279

原创 leetcode-Permutations

Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].public class

2015-01-09 10:05:48 346

原创 leetcode-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 /*what if

2015-01-09 06:57:04 337

原创 leetcode-add binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".public class Solution { public String addBinary(String a, String b) {

2015-01-09 06:06:15 317

原创 leetcode-add two numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link

2015-01-09 05:16:57 285

原创 leetcode-palindrome number

public boolean isPalindrome(int x) { if(x<0)return false; int y=0; int z=x; while(z>0){ int cur=z%10; y=y*10+cur; z=z/10; }

2015-01-08 13:23:15 339

原创 leetcode-sum root to leaf numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the tota

2015-01-08 11:25:58 407

原创 leetcode-letter combination of a phone number

Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st

2015-01-08 06:04:27 310

原创 leetcode-generate parentheses

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()

2015-01-08 05:13:09 286

原创 leetcode-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:Element

2015-01-08 05:02:03 264

原创 leetcode-3 closest

题目:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exac

2015-01-08 04:52:00 327

原创 leetcode-trapping rain water

Trapping rain water的最naive的方法:onepass没有注意到的问题:1一个container的两端应该是取最小的高度。2在找第一个容器的左端的时候没有注意到数组的下标的界限的问题!注意当数组的下标有变化的时候一定紧跟着不要忘记对其范围进行限制。3解题思路是:先找到第一个容器的最左端的点,然后用一个函数去找这个容器的右端,这个右端或者是大于等于这个容器的左端,

2015-01-08 04:43:34 373

原创 leetcode-3Sum总结

public class Solution { public List> threeSum(int[] num) { ArrayList> result=new ArrayList>(); int len=num.length; if(len==0)return result; Arrays.sort(num);

2015-01-06 03:26:58 372

空空如也

空空如也

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

TA关注的人

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