![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java
森哥在奋斗
这个作者很懒,什么都没留下…
展开
-
Leetcode_Add Two Numbers
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 numbe原创 2015-04-26 13:51:00 · 423 阅读 · 0 评论 -
java——堆、栈、常量池、equal、==、hashcode
参考:http://blog.csdn.net/andy_miao858/article/details/8302309JAVA和C语言一个很大的不同就是:在C语言中我们可以通过“&”很容易的获取一个对象的地址,而在JAVA中,我们却似乎找不到什么方法可以获取到对象的地址(有人可能以为hashcode就代表地址,其实不然,两个不同的对象hashcode完全可能一样),但绝不代表JA转载 2015-05-04 10:00:41 · 451 阅读 · 1 评论 -
LeetCode_Regular Expression Matching
Regular Expression Matching Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The mat原创 2015-05-01 19:36:42 · 383 阅读 · 0 评论 -
LeetCode_3Sum
3SumGiven an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a trip原创 2015-05-18 16:03:43 · 320 阅读 · 0 评论 -
LeetCode_Letter Combinations 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-05-24 10:19:21 · 360 阅读 · 0 评论 -
LeetCode_Remove Nth Node From End of List
题目:Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the原创 2015-08-26 17:07:12 · 348 阅读 · 0 评论 -
Merge Two Sorted Lists
题目:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.分析:题目要求合并两个已排序的链表,这里指的是两个从小到大排好序的,合并完成的链表也是有序的,从原创 2015-08-27 18:40:55 · 323 阅读 · 0 评论 -
LeetCode_Valid Parentheses
题目如下: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原创 2015-08-27 17:20:47 · 275 阅读 · 0 评论 -
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-08-28 16:47:54 · 542 阅读 · 0 评论 -
LeetCode_Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Divide and Conquer Linked List Heap分析:题目要求将若干个已排好序的ListNode合并成一个有序的ListNode,可以看做“原创 2015-08-31 16:02:19 · 330 阅读 · 0 评论 -
LeetCode_Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is原创 2015-09-02 14:27:42 · 305 阅读 · 0 评论 -
LeetCode_Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y原创 2015-09-01 16:17:30 · 390 阅读 · 0 评论 -
LeetCode_Remove Duplicates from Sorted Array
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 place with原创 2015-09-03 13:33:13 · 284 阅读 · 0 评论 -
LeetCode_Remove Element
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 length.分原创 2015-09-06 10:20:47 · 265 阅读 · 0 评论 -
LeetCode_Submission Details
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible o原创 2015-09-14 11:28:33 · 370 阅读 · 0 评论 -
LeetCode_Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",原创 2015-09-15 11:01:40 · 309 阅读 · 0 评论 -
java-数据类型总结
原文地址:http://www.cnblogs.com/doit8791/archive/2012/05/25/2517448.html1. Java的简单类型及其封装器类Java基本类型共有八种,基本类型可以分为三类,字符类型char,布尔类型boolean以及数值类型byte、short、int、long、float、double。数值类型又可以分为整数类型byte、short转载 2015-11-03 11:17:46 · 361 阅读 · 0 评论 -
LeetCode_Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array retur原创 2015-09-16 11:07:08 · 365 阅读 · 0 评论 -
java垃圾回收机制 详细分析
参考 http://blog.csdn.net/zsuguangh/article/details/64295921. 垃圾回收的意义 在C++中,对象所占的内存在程序结束运行之前一直被占用,在明确释放之前不能分配给其它对象;而在Java中,当没有对象引用指向原先分配给某个对象的内存时,该内存便成为垃圾。JVM的一个系统级线程会自动释放该内存块。垃圾回收意味着程序不再需要的对象是转载 2015-05-03 20:22:56 · 408 阅读 · 0 评论 -
LeetCode_Palindrome Number
Palindrome Number Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting原创 2015-04-30 19:44:21 · 275 阅读 · 0 评论 -
LeetCode_Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo原创 2015-04-26 17:27:07 · 304 阅读 · 0 评论 -
给出一个数和一个有序数组,找出该数组中之和等于该数的两个数
今天写的一个版本:1、有序数组,先写一个二分查找的方法private static int[] erfen(int[] a,int left,int right,int num) { //left:数组a的左边界 //right:数组a的右边界 //num:目标数 //返回int[0]是是否找到了该数,1为找到了,0为未找到;int[1]是如果找到了则返回改数的序号,如果未原创 2015-04-26 09:29:41 · 1230 阅读 · 0 评论 -
LeetCode_Two Sum
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原创 2015-04-26 09:55:13 · 411 阅读 · 0 评论 -
各类查找算法及Java实现
一 线性查找 又称顺序查找,是从数组的第一个元素开始查找,直到找到待查找元素的位置,直到查找到结果。 最佳的状况时间是1 ,就是第一个就是待查找的远射,最差的查找状况是O(n),就是最后一个是待查找的元素。 二 折半查找 折半查找是将待查找的数组元素不断的分为两部分,每次淘汰二分之一,但是有个大前提是,元素必须是有序的,如果是无序的则要先进行排序操作,这种查找的方法,类似于找英转载 2015-04-25 10:31:35 · 430 阅读 · 0 评论 -
各种排序算法的分析及java实现
排序大的分类可以分为两种:内排序和外排序。在排序过程中,全部记录存放在内存,则称为内排序,如果排序过程中需要使用外存,则称为外排序。下面讲的排序都是属于内排序。 内排序有可以分为以下几类:(1)、插入排序:直接插入排序、二分法插入排序、希尔排序。(2)、选择排序:简单选择排序、堆排序。(3)、交换排序:冒泡排序、快速排序。(4)、归并排序(5)、基数排序 一、插入转载 2015-04-25 10:39:25 · 484 阅读 · 0 评论 -
二叉树的各种遍历(先序、中序、后续、层次)——递归、非递归
package btree;import java.util.Queue;import java.util.Stack;import java.util.concurrent.LinkedBlockingQueue;public class Btree { /** * 结点类。 * @author Bao Yiming */ cla原创 2015-04-25 10:45:10 · 467 阅读 · 0 评论 -
快速排序的一种java实现
首先上一张图:然后写出如下java代码,请多多指正:public class quickSort { public static void main(String[] args) { int[] a = new int[]{6,3,9,14,12,7,2}; mysort(a,0,a.length-1); for(int i =0;i<a.length;i++)原创 2015-04-25 17:12:35 · 327 阅读 · 0 评论 -
LeetCode_ZigZag Conversion
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 legibilit原创 2015-04-29 09:13:42 · 310 阅读 · 0 评论 -
LeetCode_String to Integer (atoi)
String to Integer (atoi) Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourse原创 2015-04-29 21:38:13 · 555 阅读 · 0 评论 -
string、StringBuffer、StringBuilder解析
String的值是不可变的,这就导致每次对String的操作都会生成新的String对象,不仅效率低下,而且大量浪费有限的内存空间,StringBuffer是可变类,和线程安全的字符串操作类,任何对它指向的字符串的操作都不会产生新的对象,StringBuffer和StringBuilder类功能基本相似1. String 类 String的值是不可变的,这就导致每次对String的操作转载 2015-04-25 10:27:19 · 272 阅读 · 0 评论 -
LeetCode_Reverse Integer
Reverse Integer Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Have you thought about this?Here are some good questions to ask before codi原创 2015-04-29 09:59:42 · 467 阅读 · 0 评论 -
LeetCode_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 should be O(log (m+n)).意思是有两个已排好序的数组(经过检验,这原创 2015-04-27 12:46:29 · 315 阅读 · 0 评论 -
LeetCode_Container With Most Water
Container With Most Water Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of li原创 2015-05-02 16:57:43 · 428 阅读 · 0 评论 -
LeetCode_Longest Palindromic Substring
Longest Palindromic Substring Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palind原创 2015-04-27 19:53:17 · 271 阅读 · 0 评论 -
LeetCode_Roman to Integer
Roman to Integer Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.题目要求输入罗马数字(字符串),输出相应的整形数字,范围从1~3999.从百度百科摘抄了以下罗马数字的规则:原创 2015-05-02 20:28:31 · 294 阅读 · 0 评论 -
LeetCode_Longest Common Prefix
Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings.题目要求找出一个字符串数组中所有字符串的最长公共前缀字符串,比如{"abcde","abcdefg","abqq"},最长公共前缀字符串为“ab”。需要注意原创 2015-05-02 21:00:30 · 299 阅读 · 0 评论 -
synchronized与static synchronized
synchronized与static synchronized 的区别 synchronized是对类的当前实例进行加锁,防止其他线程同时访问该类的该实例的所有synchronized块,注意这里是“类的当前实例”, 类的两个不同实例就没有这种约束了。那么static synchronized恰好就是要控制类的所有实例的访问了,static synchronized是限制线转载 2015-04-30 18:48:54 · 357 阅读 · 0 评论 -
LeetCode_Group Anagrams
Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]Note:原创 2015-11-09 19:04:25 · 390 阅读 · 0 评论