码迷,mamicode.com
首页 >  
搜索关键字:Arrays    ( 3585个结果
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) to hold addition...
分类:其他好文   时间:2015-08-20 19:01:02    阅读次数:177
9.11排序与查找(二)——对字符串数组进行排序,将所有的变位词排在相邻的位置
/**  * 功能:对字符串数组进行排序,将所有的变位词排在相邻的位置。  */ 两种方法: 方法一: /** * 思路:套用排序算法,并修改比较器。这里比较器用来指示两个字符串胡伟变位词就是相等的。 * @param array */ public static void sort(String[] array){ Arrays.sort(array, ne...
分类:编程语言   时间:2015-08-20 18:58:42    阅读次数:168
使用json-lib进行Java和JSON之间的转换
1. json-lib是一个java类库,提供将Java对象,包括beans, maps, collections, java arrays and XML等转换成JSON,或者反向转换的功能。2. json-lib 主页 :http://json-lib.sourceforge.net/3.执行环...
分类:编程语言   时间:2015-08-20 01:21:27    阅读次数:129
求两个有序数组的中位数
1 题目 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find themedian of the two sorted arrays. The overall run time complexity should beO(log (m+n)). 2 分析 若m+n为奇数则中位数(med...
分类:编程语言   时间:2015-08-19 20:29:16    阅读次数:169
leetcode——Median of Two Sorted Array
原题为: 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-08-19 17:54:35    阅读次数:119
Java 复习 —— 集合与数组的转换
前言: ? ? 很多时候,你会觉得数组使用方便,有些时候你会觉得集合使用更加方便,你们对于集合和数组的转换那就在所难免了,下面总结一下数组与集合的转换。 1、把数组转为集合?Arrays.asList()? 1)网上解释...
分类:编程语言   时间:2015-08-19 15:04:00    阅读次数:146
Java中Comparator接口和Comparable接口的使用
一般情况下在实现对对象元素的数组或集合进行排序的时候会用到Comparator和Comparable接口,通过在元素所在的类中实现这两个接口中的一个,然后对数组或集合调用Arrays.sort或者Collentions.sort方法即可实现对数组或集合的排序。就sort方法里面的参数来说,实现了不同的接口则传递的参数也不尽相同。对于实现了Comparator接口的类来说,sort方法需要接受的参数不...
分类:编程语言   时间:2015-08-19 11:15:43    阅读次数:274
公共字串计算
import java.util.Arrays; import java.util.Scanner; public class GetCommonString { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String str1 = scan.next().toLo...
分类:其他好文   时间:2015-08-19 00:45:18    阅读次数:135
Java集合(14)--双枢轴快速排序(DualPivotQuicksort)
JDK1.7 java.uti.Arrays开始使用DualPivotQuicksort作为默认排序方法详细讲解链接:http://www.tuicool.com/articles/BfY7Nz算法思想:选出两个枢轴P1和P2,需要3个指针L,K,G。3个指针的作用如下图:算法为以下的步骤:(数组大...
分类:编程语言   时间:2015-08-18 00:57:54    阅读次数:1430
System.arraycopy和Arrays.copyOf的比较
public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length); 用了native关键字,调用的为C++编写的底层函数,可见其为JDK中的底层函数。public st....
分类:其他好文   时间:2015-08-17 23:19:26    阅读次数:262
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!