自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Java面试常考知识点总结

1.抽象类和接口的区别

2017-07-27 10:57:27 680

原创 约瑟夫环

题目:0,1,…,n-1这n个数字排成一个圆圈,从数字0开始每次从这个圆圈里删除第m个数字。求出这个圆圈里剩下的最后一个数字。解题思路:递推公式约瑟夫环

2017-06-28 22:02:13 582

原创 扑克牌的顺子

题目:从扑克牌中随机抽5张牌,判断是不是一个顺子,即这5张牌是不是连续的。2~10为数字本身,A为1,J为11,Q为12,K为13,而大、小王可以看成任意数字。解题思路:1.排序数组; 2.统计数组中0的个数和非0数字之间的空缺总数; 3.如果0的个数大于等于空缺总数,这个数组就是连续的,反之不连续。

2017-06-27 18:46:56 629

原创 翻转单词顺序&左旋转字符串

一.翻转单词顺序解题思路:1.翻转句子中的所有字符 2.翻转每个单词中字符的顺序java实现二。左旋转字符串

2017-06-26 17:39:45 589

原创 不用加减乘除做加法

题目:写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。解题思路:1.不带进位的加:num1 ^ num2 2.进位:(num1 & num2) << 1解法一(递归)java实现:public class

2017-06-15 15:47:03 298

原创 求1+2+...+n

题目:求1+2+3+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。解题思路:1.利用&&的短路特性实现递归终止。 2.当n==0时,(n>0)&&((sum+=Sum_Solution(n-1))>0)只执行前面的判断为false就直接返回0; 3.当n>0时,执行sum+=Sum_Solution(n-1),实现递归

2017-06-15 15:40:07 812

原创 和为S的两个数字 & 和为S的连续正数序列

和为S的两个数字和为S的连续正数序列

2017-06-14 18:21:11 470

原创 归并排序及java实现

归并排序思路java实现

2017-06-13 15:55:36 392

原创 数组中的逆序对

题目:在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数P。并将P对1000000007取模的结果输出。 即输出P%1000000007 解题思路:1.归并排序; 2.在merge的时候,如果array[i] > array[j]说明从array[i]到array[mid]的数都大于array[j]。

2017-06-13 11:52:11 306

原创 丑数

题目:把只包含因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含因子7。 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第N个丑数。

2017-06-08 16:17:19 314

原创 第一个只出现一次的字符

题目:在一个字符串(1<=字符串长度<=10000)中找到第一个只出现一次的字符,并返回它的位置。解题思路:1.共遍历两次字符串,第一次遍历统计每个字符出现的次数,第二次遍历遇到次数为1的字符返回它的位置即可。 2.char占一个字节,共8位,有256种可能,我们开一个大小为256的数组来保存每个字符出现的次数。java实现

2017-06-08 15:40:31 183

原创 把数组排成最小的数

把数组排成最下的数解题思路java实现比较器大数问题

2017-06-08 11:12:38 302

原创 整数中1出现的次数(从1到n整数中1出现的次数)

题目:求整数中1出现的次数?如果要计算百位上1出现的次数,它要受到3方面的影响:百位上的数字,百位以下(低位)的数字,百位以上(高位)的数字。

2017-06-07 18:27:14 461

原创 排列组合算法总结(含Java实现)

一. 排列组合1. 排列(1)排列:(2)全排列:2. 组合:从n个元素中选择m个元素(不考虑顺序)

2017-06-06 17:23:11 957

原创 排列组合算法总结(含Java实现)

一. 排列组合1. 排列(1)排列:(2)全排列:2. 组合:从n个元素中选择m个元素(不考虑顺序)

2017-06-06 17:22:55 14080 2

原创 二分查找及其相关算法的java实现

二分查找 相关算法 总结 java实现 leetcode之first bad version k第一次出现的位置 k最后一次出现的位置

2017-05-27 11:36:48 325

原创 容易理解的快速排序算法及其相关算法的总结(含java实现方法)

快速排序思想 java实现 找中位数 找前k个数

2017-05-26 11:45:26 1568

原创 168. Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB 解题思路:逢26进1(A) publ

2017-01-13 10:49:32 278

原创 455. Assign Cookies

Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a cook

2017-01-05 19:53:34 379

原创 463. Island Perimeter

You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely s

2017-01-05 17:05:47 303

原创 Java中用dom4j解析XML信息连接Embedded derby数据库

package com.jdbc;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.util.HashMap;import java.uti

2017-01-05 14:57:06 372

原创 448. Find All Numbers Disappeared in an Array

Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Could you

2017-01-04 20:30:52 421

原创 SWT中颜色获取

//三种颜色获取方式 final Color white = new Color(display, 255, 255, 255); final Color sysBlack = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK); final Color swtBlue = SWTResourceManager.getColor(S

2016-12-29 10:41:07 2345

原创 461. Hamming Distance

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.Note: 0 ≤ x, y < 231.Examp

2016-12-20 16:22:00 450

原创 office2013安装Matytype

1.下载Matytype6.9并安装,下载地址:http://www.mathtype.cn/xiazai.html 2.打开office2013,提示“‘VBE6EXT.OLB’不能被加载”、“未知的错误(50001)”以及“由于宏安全设置,无法找到宏或宏被禁用”。 解决方法:将C:\Program Files (x86)\Common Files\microsoft shared\VBA\V

2016-11-28 20:47:56 1115

原创 202. Happy Number

Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of i

2016-11-03 17:38:53 303

原创 326. Power of Three

Given an integer, write a function to determine if it is a power of three.Follow up: Could you do it without using any loop / recursion? 解法一:Language - Java Run Time - 20ms 解题思路:暴力枚举public boolean

2016-11-01 15:55:59 355

原创 231. Power of Two

Given an integer, write a function to determine if it is a power of two.解法一:Language - Java Run Time - 2ms 解题思路:一个整数如果可以表示为2的幂次,就可以表示为100000……;从而这个数减去1就变为011111…… public boolean isPowerOfTwo(int n) {

2016-11-01 15:30:38 226

原创 405. Convert a Number to Hexadecimal

Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used.Note:All letters in hexadecimal (a-f) must be in lowercase.The hexadecimal str

2016-10-31 20:51:30 272

原创 迭代与递归

递归与迭代都是基于控制结构: 迭代用重复结构递归用选择结构递归与迭代都涉及重复: 迭代显式使用重复结构递归通过重复函数调用实现重复递归与迭代都涉及终止测试: 迭代在循环条件失败时终止递归在遇到基本情况时终止使用计数器控制重复的迭代和递归都逐渐到达终止点: 迭代一直修改计数器,直到计数器值使循环条件失败递归不断产生最初问题的简化副本,直到达到基本情况迭代和递归过程都可以无限进行

2016-10-29 16:54:47 613 1

原创 206. Reverse Linked List

Reverse a singly linked list.递归与迭代都是基于控制结构: 迭代用重复结构递归用选择结构递归与迭代都涉及重复: 迭代显式使用重复结构递归通过重复函数调用实现重复递归与迭代都涉及终止测试: 迭代在循环条件失败时终止递归在遇到基本情况时终止使用计数器控制重复的迭代和递归都逐渐到达终止点: 迭代一直修改计数器,直到计数器值使循环条件失败递归不断产生最初问

2016-10-29 16:53:08 83

原创 13. Roman to Integer

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999. 解题思路:罗马数字表示法,基本字符有7个:I,V,X,L,C,D,M,分别表示1,5,10,50,100,500,1000。在构成数字的时候,有下列规则: 相同的数字连写,所表示的

2016-10-29 14:46:09 218

原创 350. Intersection of Two Arrays II

Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note: Each element in the result should appear as many times as it

2016-10-29 13:37:15 239

原创 java中的char

char在内存中是一个ASCII码,长度为2个字节public class charTest { public static void main(String args[]){ //变量声明的什么类型输出的就是什么类型 char c = 97; System.out.println(c); //a int a = 'a';

2016-10-21 11:05:21 473

原创 一个字符串

时间限制:C/C++语言 2000MS;其他语言 4000MS 内存限制:C/C++语言 10240KB;其他语言 534528KB 题目描述: 一个字符串,含有字母数字和特殊符号等,按照以下要求写一个转换函数 1)只保留小写字母,过滤掉其他字符, 2)对过滤结果按照下述规则进行映射转换:(0import java.util.Scanner;public class Main1 {

2016-10-20 20:46:35 624

原创 org.eclipse.gef源码下载地址

https://github.com/search?utf8=✓&q=org.eclipse.gef&type=Repositories&ref=searchresults

2016-10-20 10:41:50 884

原创 216. Combination Sum III

Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.Example 1:Input: k = 3, n =

2016-10-18 15:17:55 307

原创 Java中String与StringBuffer的区别

String与StringBuffer的区别 (1). String 为不可变对象。一旦被创建,就不能修改它的值。修改时需要重新创建新的对象来保存新值。为final类。不能被继承。 (2). StringBuffer为可变对象。用构造函数来创建 StringBuffer sb = new StringBuffer();对象被建立以后,在内存中就会分配内存空间,并初始保存一个null.通

2016-10-18 11:13:47 753

原创 415. Add Strings

Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2.Note:1.The length of both num1 and num2 is < 5100.2.Both num1 and num2 contains only digits 0-9.3.B

2016-10-18 10:50:30 94

原创 412. Fizz Buzz

Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For n

2016-10-17 08:57:52 334

空空如也

空空如也

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

TA关注的人

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