自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 切割钢丝,最短为1cm ,任意三段不能构成三角形

import java.util.ArrayList;public class Main {    /*     * 总共144cm,切割成N段,最短1cm,其中任意三段都不能构成三角形,问N的最大值以及每一段的长度     * 实现过程:     *  按照斐波那契的数列进行截取,截取的长度和<=144     */    public static void main(S...

2018-08-24 21:25:32 409

原创 归并排序

import org.junit.Test;public class solution {    @Test    public void test2() {        int[] arr={9,8,7,6,5,4,3,2,1};        mergeSort(arr, 0, arr.length-1);        for(int ele:arr){         ...

2018-07-20 20:44:13 196

原创 快速排序

import org.junit.Test;public class solution {    @Test    public void test2() {        int[] arr={3,2,1};        quickSort(arr, 0, arr.length-1);        for(int ele:arr){            System.ou...

2018-07-20 09:38:39 193

原创 送货路线

 import java.util.ArrayList;import java.util.Scanner;import org.junit.Test;public class solution {    @Test    public void test2(){        Scanner scanner = new Scanner(System.in);        S...

2018-07-18 18:33:00 464

原创 小朋友发糖果,相邻小朋友高分比低分的糖果多,最少需要多少糖果

import java.awt.Adjustable;import java.util.Stack;import org.junit.Test;public class Test1 {    @Test    public void testFunc() {        int[] arr = {2,4,5,2,3};        int res = minNum(arr)...

2018-07-18 17:02:52 968

原创 求两个整数之和,不能使用加减乘除四个运算符

 import java.util.ArrayList;import java.util.DuplicateFormatFlagsException;import org.junit.Test;public class solution {    @Test    public void testFunc(){        int res = addSum(1, 2);  ...

2018-07-16 23:10:33 566

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

import java.util.ArrayList;import java.util.DuplicateFormatFlagsException;import org.junit.Test;public class solution {    @Test    public void testFunc(){        int res = sum1(2);        Sy...

2018-07-16 22:36:29 136

原创 滑动窗口的最大值

 import java.util.ArrayList;import org.junit.Test;public class solution {    @Test    public void testFunc(){        int[] arr={2,3,4,2,6,2,5,1};        searchMax(arr, 3);        }//    滑...

2018-07-16 21:06:10 114

原创 翻转语句顺序

 import org.junit.Test;public class solution {    @Test    public void testFunc(){        String string = "i am a studeng.";        String res = reverseWord(string);        System.out.println...

2018-07-16 17:11:19 162

原创 数组中除两个数只出现1次外,其他数字均出现两次

 import org.junit.Test;public class solution {    @Test    public void testFunc(){        int[] arr= {2,4,3,6,3,2,5,5};        int[] searchNum = searchNum(arr);        System.out.println("num...

2018-07-16 16:18:37 277

原创 判断一棵树是不是平衡二叉树

import org.junit.Test;public class solution {    @Test    public void testFunc(){    TreeNode root1 = new TreeNode(1);    TreeNode root2 = new TreeNode(2);    TreeNode root3 = new TreeNode(3);    Tree...

2018-07-16 15:20:53 345

原创 把数字翻译成字符串---记忆化存储

import java.util.Arrays;import java.util.Comparator;import org.junit.Test;public class solution {    @Test    public void testFunc(){        int res = search(22);        System.out.println("res: "+res...

2018-07-16 08:30:30 240

原创 把数字翻译成字符串

import java.util.Arrays;import java.util.Comparator;import org.junit.Test;public class solution {    @Test    public void testFunc(){        int res = searchNum("12258", 0);        System.out.println(...

2018-07-16 08:15:55 432

原创 把数组排成最小的数

import java.util.Arrays;import java.util.Comparator;import org.junit.Test;public class solution {    @Test    public void testFunc(){        int[] arr = {3,32,321};        String minNum = minNum(arr);...

2018-07-16 07:39:49 87

原创 数字序列中某一位的数字

import org.junit.Test;public class solution {    @Test    public void testFunc(){        char res = locationNum(13);        System.out.println("res: "+res);                    }    //数字序列中的某一位数字    pu...

2018-07-15 13:50:42 299

原创 连续子数组的最大和

import org.junit.Test;public class solution {    @Test    public void testFunc(){        int[] arr={1,-2,3,10,-4,7,2,-5};        int res=maxSubArr(arr);        System.out.println("res: "+res);        ...

2018-07-15 09:40:40 101

原创 判断二叉树B是不是二叉树A的子结构

import org.junit.Test;public class solution {    @Test    public void testFunc(){        TreeNode root1 = new TreeNode(1);        TreeNode root2 = new TreeNode(2);        TreeNode root3 = new TreeNode...

2018-07-14 21:42:33 227

原创 打印从1到n的最大n位数---全排列---大数问题

import java.io.PrintStream;import org.junit.Test;public class solution {    @Test    public void testFunc(){        printN(2);            }        @Test    public void test2(){        printNum("01"); ...

2018-07-14 18:30:08 479

原创 把26进制的字母转成10进制

import org.junit.Test;public class solution {    @Test    public void testFunc(){        String string="AA";        int res = transbase10(string);        System.out.println("res: "+res);              ...

2018-07-14 15:13:14 4082

原创 判断矩阵中是否存在某个字符串路径

import org.junit.Test;public class solution {    @Test    public void testFunc(){        char[][] matrix = {                {'a','b','t','g'},                {'c','f','c','s'},                {'j','d'...

2018-07-14 14:18:04 427

原创 中序遍历下某个元素的下一个节点---考察中序遍历的非递归实现

import java.util.ArrayList;import java.util.HashMap;import java.util.HashSet;import java.util.Map.Entry;import java.util.Set;import java.util.Stack;import org.junit.Test;public class solution {    @Te...

2018-07-14 09:57:56 163

原创 计算出第一个文本中包含第二个文本每个单词的最短文本

import java.util.ArrayList;import java.util.HashMap;import java.util.HashSet;import java.util.Map.Entry;import java.util.Set;import org.junit.Test;public class solution {    @Test    public void testF...

2018-07-14 08:06:16 275

原创 反转int型数据

import org.junit.Test;public class solution {    @Test    public void testFunc(){        int res = reverseInt(123);        System.out.println("res: "+res);    }//    反转int型数据    public int reverseInt(...

2018-07-13 00:07:50 935

原创 字符串的逆序--手写

import org.junit.Test;public class solution {    @Test    public void testFunc(){        String string = "hello";        String reString = reverseString(string);        System.out.println("res: "+reSt...

2018-07-12 23:15:56 1318

原创 判断一棵树是否为BST----使用递归方法

import org.junit.Test;public class solution {    @Test    public void testFunc(){                    }        public boolean isBST(TreeNode root){        return isBST2(root, Integer.MIN_VALUE, Integer...

2018-07-12 22:52:20 629

原创 字符串转int类型

import org.junit.Test;public class solution {    @Test    public void testFunc(){//    String string = "-10";    String string = "10";    int res = parseInt(string);    System.out.println("res: "+res)...

2018-07-12 21:12:25 9022

原创 求两个数的最大公约数

import org.junit.Test;public class solution {    @Test    public void testFunc(){        int maxYueShu = maxYueShu(12, 8);        System.out.println("res: "+maxYueShu);                }        public ...

2018-07-12 20:47:21 166

原创 把某种格式的字符串转化为驼峰字符串

import org.junit.Test;public class solution {    @Test    public void testFunc(){        String  string = " border-left-color";        String res = hump(string);        System.out.println("res: "+res)...

2018-07-12 17:44:28 746

原创 青蛙跳台的递归实现

import org.junit.Test;public class solution {    @Test    public void testFunc() throws Exception{        int res = jumpStar(5);        System.out.println("res: "+res);                }    private int...

2018-07-12 16:42:49 279

原创 后序遍历的非递归实现---利用栈

    //后续遍历的非递归实现    public void postOrder(TreeNode root){        Stack<TreeNode> stack = new Stack<TreeNode>();        TreeNode p = root;        stack.push(p);        TreeNode pre = null; ...

2018-07-12 16:10:44 2276

原创 中叙遍历的非递归实现---利用栈

//中叙遍历的非递归实现---利用栈    public void inOrder(TreeNode root){        Stack<TreeNode> stack = new Stack<TreeNode>();        TreeNode p = root;        while (p!=null || !stack.isEmpty()) {      ...

2018-07-12 14:28:08 97

原创 前序遍历的非递归实现--利用栈

import java.io.BufferedReader;import java.io.FileReader;import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.HashMap;import java.util.Map;import java.ut...

2018-07-12 14:14:59 542

原创 一个文件,其中内容以换行与空格作为每个单词的分隔,手写代码,将单词按单词的出现次数排序

import java.io.BufferedReader;import java.io.FileReader;import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.HashMap;import java.util.Map;import java.ut...

2018-07-11 16:37:17 706 1

原创 求一个数组每个元素右边第一个比它大的元素/单调栈

import java.util.Stack;import org.junit.Test;public class solution {    @Test    public void testFunc(){        int[] arr = {13,7,6,12};        int[] res = get(arr);        for(int ele:res){          ...

2018-07-11 14:05:59 1967

原创 coin change

import org.junit.Test;public class solution {    @Test    public void testFunc(){        int[] arr = {5,2,3};        int target =20;        int res = charge(arr, target);        System.out.println("re...

2018-07-10 22:18:37 151

原创 求n以内的最大质数

package codePra;import org.junit.Test;//求n以内的最大质数public class helloword {    @Test    public void testFunc(){        int res = maxPrime(10);        System.out.println("res: "+res);    }    /*     * 使用...

2018-07-09 23:36:41 3247

原创 单例模式之懒汉式

//单例模式之懒汉式public class Singleton {    private Singleton() {        // TODO Auto-generated constructor stub    }    private static Singleton instance;    public static synchronized Singleton getInstanc...

2018-07-09 22:36:10 77

原创 单例模式之饿汉式

//单例模式之饿汉式public class Singleton {    private Singleton() {        // TODO Auto-generated constructor stub    }    private static Singleton instance = new Singleton();    public static Singleton getIn...

2018-07-09 22:32:49 73

原创 两个字符串的最长公共子序列

import org.junit.Test;public class solution {        @Test    public void testFunc(){        String s1 = "ABCD";        String s2 = "AEBD";        int res = minDistance(s1, s2);        System.out.prin...

2018-07-09 22:27:08 148

原创 在N个元素中选取前M个元素

import org.junit.Test;public class solution {        @Test    public void testFunc(){//        int[] arr = {5,4,3,2,1};        int[] arr = {1,2,3,4,5,6};        maxArr(arr,3);        for(int i=0;i<...

2018-07-09 20:40:44 576

空空如也

空空如也

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

TA关注的人

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