自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 Isomorphic Strings

public class Solution { public boolean isIsomorphic(String s, String t) { char[] map1 = new char[256], map2 = new char[256]; /*ASCII字符串共有256个,所以设为256*/ for (int i = 0; i <

2015-05-25 05:24:17 306

转载 Java String类知识总结并结合leetcode

字符串类型的转换 /* You convert primitive types to a string with toString 033 * String byteString = Byte.toString(bigByte); 034 * String shortString = Short.toString(bigByte); 035

2015-03-21 08:47:19 636

转载 Multivision面试材料准备学习之HTML

What is HTML? HTML is a markup language for describing web documents A markup language is a set of markup tags HTML Basic Examples My First Heading My first paragraph. This

2015-03-09 11:55:15 654

原创 Longest Substring Without Repeating Characters

import java.util.Hashtable;//漏写 public class Solution { public int lengthOfLongestSubstring(String s) { Hashtable checkrepeatation = new Hashtable(); int i=1, j=0, currlength=1, lo

2015-03-03 00:57:14 259

转载 Anagrams

public class Solution { public List anagrams(String[] strs) { Map map = new HashMap(); Set set = new HashSet(); List result = new LinkedList(); if(strs.length == 0

2015-03-02 10:05:38 293

原创 Binary Tree Postorder Traversal

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { publi

2015-03-01 03:54:33 362

原创 Binary Tree Inorder Traversal

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { publi

2015-02-28 13:47:24 404

转载 Binary Tree Preorder Traversal

//recursion vs iteration 递归与迭代 //递归与迭代都是基于控制结构:迭代用重复结构,而递归用选择结构。 //递归与迭代都涉及重复:迭代显式使用重复结构,而递归通过重复函数调用实现重复。 //递归与迭代都涉及终止测试:迭代在循环条件失败时终止,递归在遇到基本情况时终止。 //先序遍历是先访问根结点,再左子树,再右子树(即: 根>左>右) //解题思想,不断地把左结点放入l

2015-02-28 11:43:27 282

原创 Single Number II

解题思路:用一个长度为32的数组a代表32个bit。用它记录下数组A中每一个元素在每一个bit上出现的次数(0次或1次)。然后对每个bit(即数组a的每个元素) 除3取余(出现三次的数,在每个bit上出现的次数叠加后,要么是3要么是0),每个bit余下来的值便是出现一次的数的每个bit上的值。最后根据每个bit的值,转成十进制的,便是出现一次的数。 public class Solution {

2015-02-25 02:31:19 296

原创 Single Number

用异或的方法,灰常简单 public class Solution { public int singleNumber(int[] A) { int i = 0, j =0; for(; i < A.length; i++ ) j = j ^ A[i]; return j; } } 下面这个是错误的代码,用hashtabl

2015-02-24 02:26:02 279

原创 Valid Sudoku

import java.util.Hashtable; public class Solution { public boolean isValidSudoku(char[][] board) { int i, j, hit=0; for(i = 0; i <= 8 && hit == 0; i++) { Hashta

2015-02-23 13:53:34 396

转载 Unique Binary Search Trees

public class Solution { public int numTrees(int n) { /* 解题关键:有n个结点的Tree的structure数量等于 左子树结点数等于0 ~ (n-1)时structure数量分别乘以右子树等于(n-1) ~ 0时structure数量之积的和 */ if(n

2015-02-15 08:30:41 248

转载 Climbing Stairs

public class Solution { public int climbStairs(int n) { if(n == 0){ //n为零,零种走法 return 0; } if(n == 1){ //n为一,一种走法 return 1; }

2015-02-13 14:20:52 256

原创 Roman to Integer

public class Solution { public int romanToInt(String s) { int answer = 0; int i = 0; int len = s.length(); while(i < len) { int x=0;

2015-02-13 05:31:28 257

原创 Merge Two Sorted Lists

/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */ public

2015-02-12 15:18:36 272

原创 Remove Duplicates from Sorted List

/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */ public

2015-02-11 13:20:32 284

原创 Remove Nth Node From End of List

//一审题才发现,Try to do this in one pass. 是双指针的思想。但这样代码运行速度比平均速度要快/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { *

2015-02-11 10:23:14 290

原创 LeetCode Path Sum

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { publi

2015-02-11 09:44:28 260

原创 Valid Palindrome

//palindrome回文 //我们只能考虑alphanumeric (字母与数字)。所以必须要找一个判别字母和数字的方法。int value=Integer.valueOf("1");//49 //所以我的想法用数组,存下有效的ASCII,做做比较 // //还需注意ignoring cases. public class Solution { public boolean isPal

2015-02-06 01:06:24 270

转载 ZigZag Conversion

public class Solution { public String convert(String s, int nRows) { int len = s.length();//len即为字符串长度 if(len<=nRows||nRows<=1) return s; //such condition can't form the zigzag rou

2015-02-04 23:46:43 308

原创 Binary Tree Level Order Traversal II

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ //import java.util.Arrays;import

2015-01-28 06:48:40 240

原创 Binary Tree Level Order Traversal

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { publi

2015-01-26 08:49:18 277

原创 leetocde banlanced binary tree

public class Solution {     public boolean isBalanced(TreeNode root)      {         if(root == null) return true;         if(isbalanced(root)==-1) return false;         return true;     }     p

2015-01-24 06:15:13 323

空空如也

空空如也

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

TA关注的人

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