![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Java
文章平均质量分 51
beryl_lu
这个作者很懒,什么都没留下…
展开
-
Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element原创 2016-09-23 10:09:28 · 176 阅读 · 0 评论 -
Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Java中int型范围:-2^32 - 2^32-1(2147483647 - -2147483648),也可以用Integer.MAX_VALUE - Integer.MIN_VALUE表示。原创 2016-10-09 20:48:32 · 148 阅读 · 0 评论 -
折半插入排序(数组实现)
折半插入排序:先折半查找出待插入元素的位置,再统一向后移动待插入元素后面的所有元素。 也是一种稳定的排序算法。 public class InsertHalf { public static void inserthalf(int [] s, int num ){ int i,j,temp,low,high,mid; for(i=1;i if (s[i] temp=s[i]; lo原创 2016-10-10 20:17:27 · 338 阅读 · 0 评论 -
直接插入排序(数组实现)
插入排序:每次将一个待排序的记录,按照其关键字的大小插入到前面已经排好序的子序列中,直到全部记录插入成功。 三类:直接插入排序,折半插入排序,希尔排序 直接插入排序; 1、查找到L[i]在L[1,2...,i-1]的插入位置k。 2、将L[k,...,i-1]中的所有元素全部后移一个位置。 3、将L[i]复制到L[k]的位置。 JAVA实现: public class原创 2016-10-10 19:46:38 · 333 阅读 · 0 评论 -
冒泡排序(数组实现)
交换排序:根据序列中2个关键字的比较结果来对换这两个记录在序列中的位置。 基于交换的排序算法:冒泡排序和快速排序 冒泡排序: 假设n个待排序的记录,从后往前或从前往后两两比较相邻元素的值,若为逆序((s[j] public class BubbleSort { public static void main(String[] args) { int [] s={1,5,7,11,2原创 2016-10-11 19:11:46 · 373 阅读 · 0 评论 -
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 legibility) P A H N A P L S I原创 2016-09-27 21:28:04 · 182 阅读 · 0 评论 -
判断回文序列
利用递归的思想 每次判断第一个与最后一个字符是否相等,相等则将第二个与倒数第二个字符进行比较,。。。,直到剩下最后一个字符(如果待判断字符串是奇数)或没有字符(如果待判断字符串个数是偶数)。 public class HuiWen { public static int huiwen(int low,int high,char[] a, int length){ if (lengt原创 2016-10-18 14:13:47 · 899 阅读 · 0 评论