自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 判断回文序列

利用递归的思想每次判断第一个与最后一个字符是否相等,相等则将第二个与倒数第二个字符进行比较,。。。,直到剩下最后一个字符(如果待判断字符串是奇数)或没有字符(如果待判断字符串个数是偶数)。public class HuiWen {public static int huiwen(int low,int high,char[] a, int length){if (lengt

2016-10-18 14:13:47 899

原创 冒泡排序(数组实现)

交换排序:根据序列中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 372

原创 折半插入排序(数组实现)

折半插入排序:先折半查找出待插入元素的位置,再统一向后移动待插入元素后面的所有元素。也是一种稳定的排序算法。public class InsertHalf {public static void inserthalf(int [] s, int num ){int i,j,temp,low,high,mid;for(i=1;iif (s[i]temp=s[i];lo

2016-10-10 20:17:27 337

原创 直接插入排序(数组实现)

插入排序:每次将一个待排序的记录,按照其关键字的大小插入到前面已经排好序的子序列中,直到全部记录插入成功。三类:直接插入排序,折半插入排序,希尔排序直接插入排序;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

原创 Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Java中int型范围:-2^32 - 2^32-1(2147483647 - -2147483648),也可以用Integer.MAX_VALUE - Integer.MIN_VALUE表示。

2016-10-09 20:48:32 148

原创 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 NA P L S I

2016-09-27 21:28:04 181

原创 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

原创 Two sum

QuestionGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example:Give

2016-09-21 14:17:10 178 1

空空如也

空空如也

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

TA关注的人

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