自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

爱胡椒的小白兔呢

其实我写起码来超酷哒 哈哈哈 逃^_^

  • 博客(81)
  • 收藏
  • 关注

原创 leetcode148套题

只刷剑指不行,宝宝我还要刷点别的,啊啊啊,实习了一天头好疼,但是不行,我要坚持坚持坚持!1、树:minimum-depth-of-binary-tree题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the

2017-09-06 22:55:31 445

原创 剑指offer

艾瑞巴蒂,我来刷剑指了,因为要找工作了呀~ ^_^ 紧急紧急!!!这里来记录下~1、二维数组的查找:题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。思路:从右上角开始,比目标大的话往左走;比目标小的话,向下走。源码:public class Solution

2017-09-06 22:47:29 484

原创 剑指offer刷刷题

1、编程实现设计模式:Singleton(单例模式)public class Singleton{ private Singleton(){} private static Singleton s = new Singleton(); public static Singleton getSingleton() { return s; }}

2017-07-18 22:35:15 647

原创 Leetcode刷题记——50. Pow(x, n)

一、题目叙述:Implement pow(x, n).二、解题思路:Medium题。&参考。思路:递归实现,注意n为负时,不能用 1 / mypow(x, -n)。三、源码:public class Solution { public double m

2017-04-13 23:08:19 317

原创 Leetcode刷题记—— 4. Median of Two Sorted Arrays(两有序数组的中位数)

一、题目叙述:There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity sh

2017-04-12 20:02:32 354

原创 背景

一、B-树:public class BTreeSET >{ private Page root = new Page(true); public BTreeSET(Key sentinel) { add(sentinel); } public boolean contains(Key key) { return contains(root, key); } priv

2017-04-10 11:11:07 252 1

原创 数据压缩

一、Huffman压缩:public class Huffman { private static int R = 256; private static class Node implements Comparable { private Node left, right; private int freq; private char ch; Node(char ch

2017-04-08 10:55:41 241

原创 正则表达式

一、NFA的构造与匹配:public class NFA { private int M; private Digraph G; private char[] re; public NFA(String regexp) { Stack ops = new Stack(); M = regexp.length(); G = new Digraph(M+1); re

2017-04-07 10:47:49 215

原创 子字符串查找

一、暴力子字符串查找算法:public class Baoli { public static int search(String pattern, String txt) { int M = pattern.length(); int N = txt.length(); for (int i = 0; i < N-M; i++) { int j; for (

2017-04-06 11:37:23 225

原创 单词查找树

一、基于单词查找树的符号表:public class TrieST{ private Node root; private static int R = 256; private static class Node { private Object val; private Node[] next = new Node[R]; } public Value get(Str

2017-04-05 21:23:01 298

原创 字符串排序

一、低位优先字符串排序算法(LSD):public class LSD{ public static void sort(String[] a, int W) { int R = 256; int N = a.length; int[] count = new int[R+1]; String[] aux = new String[N]; for (int d = W

2017-03-30 11:41:10 331

原创

一、无向图Graph数据类型:import java.util.Scanner;public class Graph{ private final int V; private int E; private Bag[] adj; public Graph(int v) { this.V = v; this.E = 0; adj = (Bag[])new Bag[

2017-03-20 18:28:50 268

原创 Leetcode刷题记—— 46. Permutations(排列)

一、题目叙述:Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2]

2017-03-13 20:18:22 231

原创 符号表

一、无序链表的顺序查找:import java.util.ArrayList;import java.util.Iterator;public class SequentialSearchST{ private Node first; private int N; private class Node { Key key; Value val; Node next

2017-03-07 11:16:01 265

原创 Leetcode刷题记—— 60. Permutation Sequence(排列序列)

一、题目叙述:The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie

2017-03-05 16:48:12 468

原创 Leetcode刷题记—— 73. Set Matrix Zeroes(设置矩阵0)

一、题目叙述:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Subscribe to see which companies ask

2017-03-05 11:04:08 687

原创 Leetcode刷题记—— Remove Duplicates from Sorted Array II(已排序数组移除重复元素2)

一、题目叙述:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should retur

2017-03-04 17:48:51 344

原创 Leetcode刷题记——75. Sort Colors(颜色排序)

一、题目叙述:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.

2017-03-04 17:23:58 432

原创 Leetcode刷题记——100. Same Tree(相同的树)

一、题目叙述:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you imp

2017-03-03 19:27:51 278

原创 Leetcode刷题记——29. Divide Two Integers(整数相除Divide two integers without using multiplication, division)

一、题目叙述:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.两整数相除,不能使用乘法,除法和取模运算。二、解题思路:Medium题,不能用乘除取模,那

2017-03-03 18:57:20 287

原创 Leetcode刷题记——136. Single Number(单独的数字)

一、题目叙述:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you imp

2017-02-28 16:41:58 237

原创 Leetcode刷题记——83. Remove Duplicates from Sorted List(删除有序链表的重复结点)

一、题目叙述:Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.

2017-02-28 15:06:35 361

原创 优先队列

一、基于堆的优先队列:public class MaxPQ>{ private int N = 0; private Key[] pq; public MaxPQ(int maxN) { pq = (Key[])new Comparable[maxN+1]; } public boolean isEmpty() { return N == 0; } publ

2017-02-28 11:33:28 196

原创 Leetcode刷题记——147. Insertion Sort List(插入排序链表)

一、题目叙述:Sort a linked list using insertion sort.二、解题思路:Medium题,啊。。。我今天头晕脑胀,写的不太顺利。代码之混乱,我现在提交成功了都还很迷。使用插入排序的方法对链表进行排序,即每次和前面的结点比找到合适的位置插入,链表不同于数组的地方在于,只能从前往后比,找到第一个比目前结点值大的结点,

2017-02-27 18:52:46 474

原创 Leetcode刷题记——70. Climbing Stairs(爬楼梯)

一、题目叙述:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Giv

2017-02-27 17:33:24 685

原创 归并排序、快速排序、堆排序

一、自顶向下的归并排序:public class Merge{ private static Comparable[] aux; public static void merge(Comparable[] a, int lo, int mid, int hi) { //aux = new Comparable[a.length]; for (int k = lo; k <= h

2017-02-27 16:22:25 182

原创 Leetcode刷题记——48. 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?Subscribe to see which companies

2017-02-26 17:18:07 500

原创 Leetcode刷题记——67. Add Binary(二进制数相加)

一、题目叙述:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".Subscribe to see which companies asked this q

2017-02-26 16:42:51 319

原创 初级排序算法实现

一、选择排序:public class Selection { public static void sort(Comparable[] a) { int N = a.length; for (int i = 0; i < N; i++) { int min = i; for (int j = i + 1; j < N; j++) if (less(a[j

2017-02-26 11:15:51 231

原创 Leetcode刷题记——59. Spiral Matrix II(螺旋矩阵2)

一、题目叙述: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:[ [

2017-02-25 20:02:43 453

原创 Leetcode刷题记——58. Length of Last Word(最后一个单词的长度)

一、题目叙述:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, r

2017-02-25 19:34:35 623

原创 union-find算法

一、quick-find:import java.util.Scanner;public class UF //quick-find{ private int[] id; private int count; public UF(int N) { count = N; id = new int[N]; for (int i = 0; i < N; i++)

2017-02-25 19:17:41 266

原创 Leetcode刷题记——54. 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

2017-02-23 19:00:37 749

原创 Leetcode刷题记——53. Maximum Subarray(最大子串)

一、题目叙述:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous

2017-02-23 17:24:42 241

原创 Leetcode刷题记——41. First Missing Positive(第一个丢失的正数)

一、题目叙述: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) tim

2017-02-22 21:19:27 319

原创 Leetcode刷题记——88. Merge Sorted Array(合并有序数组)

一、题目叙述:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n

2017-02-22 20:17:52 269

原创 Leetcode刷题记——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

2017-02-21 18:39:36 312

原创 Leetcode刷题记—— 84. Largest Rectangle in Histogram(柱形图中最大矩形面积)

一、题目叙述:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogra

2017-02-21 18:05:04 381

原创 背包、队列、栈

一、定容栈public class FixedCapacityStackOfStrings { private String[] a; private int N; public FixedCapacityStackOfStrings(int cap) { a = new String[cap]; } public void push(String item) { a

2017-02-21 16:04:14 217

原创 Leetcode刷题记—— 66. Plus One(加1)

一、题目叙述:Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not co

2017-02-07 23:07:07 1465

空空如也

空空如也

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

TA关注的人

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