自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 【Leetcode】169. Majority Element

169. Majority ElementGiven an array of size n, find the majority element. The majority element is the element that appearsmore than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and

2016-07-24 23:39:51 248

转载 【Java】排序之Java的Sort函数

排序之Java中的Sort函数java中Arrays.sort使用了两种排序方法,快速排序和优化的合并排序。快速排序主要是对哪些基本类型数据(int,short,long等)排序。而合并排序用于对对象类型进行排序。原因:使用不同类型的排序算法主要是由于快速排序是不稳定的,而合并排序是稳定的。这里的稳定是指比较相等的数据在排序之后仍然按照排序之前的前后顺序

2016-07-24 22:36:40 659

转载 【Java】HashMap的两种排序方式

http://www.cnblogs.com/lovebread/archive/2009/11/23/1609121.htmlMap map = new HashMap();map.put("d", 2);map.put("c", 1);map.put("b", 1);map.put("a", 3);List> infoIds = new ArrayList>(map.e

2016-07-24 21:47:17 422

原创 【Leetcode】70. Climbing Stairs 【动态规划】

70. Climbing StairsTotal Accepted: 119494Total Submissions: 319815Difficulty: EasyYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either c

2016-07-24 21:25:28 350

转载 【Leetcode】39

http://www.cnblogs.com/xiaoba1203/p/5600769.html

2016-07-24 18:20:35 275

原创 【Leetcode】213. House Robber II 【动态规划】

213. House Robber IINote: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too

2016-07-24 00:25:26 562

转载 【排序】白话经典算法系列

http://blog.csdn.net/MoreWindows/article/category/859207

2016-07-23 17:44:07 370

转载 【排序】【Java】Java实现几种常见排序方法

日常操作中常见的排序方法有:冒泡排序、快速排序、选择排序、插入排序、希尔排序,甚至还有基数排序、鸡尾酒排序、桶排序、鸽巢排序、归并排序等。冒泡排序是一种简单的排序算法。它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。走访数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。这个算法的名字由来是因为越小的元素会经由交换慢慢“浮”到数列的顶端。

2016-07-23 00:37:14 411

转载 【排序】稳定排序和不稳定排序

http://www.cnblogs.com/codingmylife/archive/2012/10/21/2732980.html这几天笔试了好几次了,连续碰到一个关于常见排序算法稳定性判别的问题,往往还是多选,对于我以及和我一样拿不准的同学可不是一个能轻易下结论的题目,当然如果你笔试之前已经记住了数据结构书上哪些是稳定的,哪些不是稳定的,做起来应该可以轻松搞定。本文是针对老是记不住这

2016-07-23 00:30:40 341

转载 【排序】各种排序算法时间复杂度和空间复杂度表

http://blog.chinaunix.net/uid-21457204-id-3060260.html在网上看到一个常用排序算法的时间复杂度和空间复杂度表格,自己整理了一下,如下:

2016-07-23 00:29:40 451

原创 【Leetcode】152. Maximum Product Subarray 【动态规划】

152. Maximum Product SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous

2016-07-22 01:05:33 239

转载 INT_MIN与溢出

http://blog.csdn.net/booirror/article/details/41225895隔了好久没更新了,因为我在学习PL和编译器/解释器的知识。挺好奇这方面的,因为没有学过相关的课程,所以学起来有点吃力,进展缓慢,所以导致没啥可写的。今天看到这么一段话:32位的int型的取值是2147483647 到 -2147483648,但是,

2016-07-21 23:14:00 308

原创 【Leetcode】53. Maximum Subarray【动态规划】

53. Maximum SubarrayFind 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 contiguou

2016-07-21 22:59:37 310

原创 【Leetcode】122. Best Time to Buy and Sell Stock II 【动态规划&贪心】

122. Best Time to Buy and Sell Stock IISay you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as

2016-07-21 11:25:29 388

原创 【Leetcode】121. Best Time to Buy and Sell Stock 【动态规划】

121. Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, bu

2016-07-21 10:53:04 334

原创 【Leetcode】82 Remove Duplicates from Sorted List II 【指针&链表】

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

2016-07-19 01:07:05 290

原创 【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.这道题的要求是在有序链表中删除有重复数字的节点,使其只

2016-07-19 00:01:47 233

转载 Java多线程程序设计

一:理解多线程  多线程是这样一种机制,它允许在程序中并发执行多个指令流,每个指令流都称为一个线程,彼此间互相独立。 线程又称为轻量级进程,它和进程一样拥有独立的执行控制,由操作系统负责调度,区别在于线程没有独立的存储空间,而是和所属进程中的其它线程共享一个存储空间,这使得线程间的通信远较进程简单。  多个线程的执行是并发的,也就是在逻辑上“同时”,而不管是否是物理上的“同时”。如

2016-07-17 21:57:17 319

原创 【Leetcode】344. Reverse String

344. Reverse String Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".Subscribe to see which companies ask

2016-07-17 20:59:12 620

转载 Java HashMap实现详解

1.    HashMap概述:   HashMap是基于哈希表的Map接口的非同步实现。此实现提供所有可选的映射操作,并允许使用null值和null键。此类不保证映射的顺序,特别是它不保证该顺序恒久不变。2.    HashMap的数据结构:   在java编程语言中,最基本的结构就是两种,一个是数组,另外一个是模拟指针(引用),所有的数据结构都可以用这两个基本结

2016-07-17 20:28:11 341

转载 java基本类型数组初始化

1.byte、short、int、long类型数组,数组元素默认初始化为0。byte[] i= new byte[10];//short[] i = new short[10];//int[] i = new int[10];  System.out.println(i); //是一个内存地址  //每个元素都已默认初始化为0  for(int j=0; j

2016-07-17 19:18:16 371

原创 【Leetcode】349. Intersection of Two Arrays

Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.T

2016-07-17 17:33:11 312

转载 HashSet HashTable HashMap的区别

本文转自:http://wuhenjia.blog.163.com/blog/static/93469449201124114150295/(1)HashSet是set的一个实现类,hashMap是Map的一个实现类,同时hashMap是hashTable的替代品(为什么后面会讲到).(2)HashSet以对象作为元素,而HashMap以(key-value)的一组对象作为元素

2016-07-17 17:18:50 258

转载 【Java】Java中关于HashMap的使用和遍历

http://blog.csdn.net/woshisap/article/details/68874171:使用HashMap的一个简单例子package com.pb.collection; import java.util.HashMap; import java.util.Iterator; import java.util.Set; import jav

2016-07-17 13:25:34 389

原创 【Java】用jxl.jar更改数据格式 读入写出excel

ReadXls类:导入jxl.jar 实现对Excel的基本操作package dataProcessing;import java.io.*;import java.util.ArrayList;import java.util.List;import jxl.*;import jxl.write.WritableSheet;import jxl.write.Writabl

2016-07-14 11:22:38 577

转载 jxl实例

import jxl.*;import jxl.write.*;import java.io.*;import java.io.File.*;import java.util.*;public class excel{public static void main(String[] args){String targetfile = "c:/out.xls";//输出的e

2016-07-14 11:09:35 245

转载 【Leetcode】371. Sum of Two Integers

1 解题思想这道题本身来说很简单,就是实现加法,但是不允许用内置的加减来实现,那么这个就应该怎么实现呢?和题目一样,我用的是一个位运算,分为两个步骤: 1、输入 a,b 2、按照位把ab相加,不考虑进位,结果是 a xor b,即1+1 =0 0+0 = 0 1+0=1,进位的请看下面 3、计算ab的进位的话,只有二者同为1才进位,因此进位可以标示为 (a and b) 4

2016-07-12 21:13:02 255

转载 Java 位运算(移位、位与、或、异或、非)

public class Test { public static void main(String[] args) { // 1、左移( << ) // 0000 0000 0000 0000 0000 0000 0000 0101 然后左移2位后,低位补0:// // 0000 0000 0000 0000 0000 0000 0001 0100 换算成10进制为20 Sys

2016-07-12 20:49:11 260

原创 【Leetcode】198. House 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 adjacent house

2016-07-12 00:00:06 222

原创 【Leetcode】3Sum - 【两个指针】

15. 3SumTotal Accepted: 127471Total Submissions: 659843Difficulty: MediumGiven an array S of n integers, are there elements a,b, c in S such that a + b + c = 0? Find all unique

2016-07-08 16:33:51 414

原创 Initialize List<List<Integer>> in Java 怎么初始化List<List<Integer>>

参考自:http://stackoverflow.com/questions/30401948/initialize-listlistinteger-in-java               http://stackoverflow.com/questions/31754638/listinteger-cannot-be-converted-to-arraylistinteger

2016-07-08 16:16:48 12591

原创 【Leetcode】1. Two Sum

1. Two SumTotal Accepted: 254411Total Submissions: 1031847Difficulty: EasyGiven an array of integers, return indices of the two numbers such that they add up to a specific targ

2016-07-08 11:34:35 393

原创 【Leetcode】240. Search a 2D Matrix II

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 in ascending from left to right.Integers in

2016-07-07 09:59:32 281

原创 【Leetcode】74 Search a 2D Matrix

74. Search a 2D MatrixTotal Accepted: 84883Total Submissions: 246852Difficulty: MediumWrite an efficient algorithm that searches for a value in an m x n matrix. This matrix has

2016-07-06 21:45:05 262

转载 java 递归函数

转载自:http://blog.csdn.net/guoyankun/article/details/8060896/一、递归函数,通俗的说就是函数本身自己调用自己... 如:n!=n(n-1)! 你定义函数f(n)=nf(n-1) 而f(n-1)又是这个定义的函数。。这就是递归 二、为什么要用递归:递归的目的是简化程序设计,使程序易读 三、递归的弊端:虽然非递

2016-07-06 17:21:42 2621

转载 java中int,char,string三种类型的相互转换

转载自:http://blog.csdn.net/lisa0220/article/details/6649707如何将字串 String 转换成整数 int? int i = Integer.valueOf(my_str).intValue();int i=Integer.parseInt(str);如何将字串 String 转换成Integer ?Integer int

2016-07-06 14:32:37 765

转载 java必备基础知识点

转载自:  http://www.cnblogs.com/whyhappy/p/5279802.htmlJava基础1、 简述Java的基本历史java起源于SUN公司的一个GREEN的项目,其原先目的是:为家用消费电子产品发送一个信息的分布式代码系统,通过发送信息控制电视机、冰箱等 2、 简单写出Java特点,写出5个以上,越多越好简单的、面向对象的、分布式的、安

2016-07-06 13:50:36 2810 4

原创 ?【Leetcode】67. Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".我的思路:1、转换成十进制,进行相加,然后转换成二进制输出。2、直接二进制计算然后输出。

2016-07-06 13:41:57 345

原创 【Leetcode】303 Range Sum Query - Immutable - 【动态规划】

Given an integer array nums, find the sum of the elements between indicesi and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRa

2016-07-06 01:36:54 1071

原创 【Leetcode】234 Palindrome Linked List

参考自http://blog.csdn.net/xudli/article/details/46871949Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?[思路]先分成大小相同(可能长度

2016-07-02 00:32:42 262

空空如也

空空如也

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

TA关注的人

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