随笔分类 -  算法

摘要:1 字符串逆序 /** * 字符串的逆序 * * @param sentense * @return */ private static String reverseString(String sentense) { return sentense.isEmpty() ? sentense : re 阅读全文
posted @ 2021-12-20 14:57 姚狗蛋 阅读(21) 评论(0) 推荐(0) 编辑
摘要:package com.siyu.leetcode; /** * 整数反转 * * * 给你一个 32 位的有符号整数 x ,返回将 x 中的数字部分反转后的结果。 * * 如果反转后整数超过 32 位的有符号整数的范围 [−231, 231 − 1] ,就返回 0。 * * 假设环境不允许存储 6 阅读全文
posted @ 2021-12-14 20:14 姚狗蛋 阅读(25) 评论(0) 推荐(0) 编辑
摘要:package com.siyu.leetcode; import java.util.HashMap; import java.util.Map; /** * 1-两数之和 * * 给定一个整数数组 nums 和一个整数目标值 target, * 请你在该数组中找出 和为目标值 target 的那 阅读全文
posted @ 2021-12-14 20:02 姚狗蛋 阅读(19) 评论(0) 推荐(0) 编辑
摘要:输入一个字符串s,我们可以删除字符串s中的任意字符,让剩下的字符串形成一个对称字符串,且该字符串为最长对称字符串。如:输入google,则找到最长对称字符串为goog;如输入abcda则能找到3个最长对称字符串为aba/aca/ada。 若最长对称字符串存在多个,则输出多个相同长度的最长对称字符串, 阅读全文
posted @ 2021-12-11 22:38 姚狗蛋 阅读(102) 评论(0) 推荐(0) 编辑
摘要:public class MyStack { private long[] arr; private int top; public MyStack(){ arr = new long[10]; top = -1; } public MyStack(int max){ arr = new long[ 阅读全文
posted @ 2021-12-11 22:37 姚狗蛋 阅读(27) 评论(0) 推荐(0) 编辑
摘要:public class MyArray { private long[] arr; private int elements;//数组长度 public MyArray(){ arr = new long[50]; } public MyArray(int maxsize){ arr = new 阅读全文
posted @ 2021-12-11 22:37 姚狗蛋 阅读(15) 评论(0) 推荐(0) 编辑
摘要:public class Recursion { public static void main(String[] args) { int rabbit = getRabbit(7); System.out.println(rabbit); } /** * 不死神兔 * 分波那契数列 * 1 1 2 阅读全文
posted @ 2021-12-11 22:35 姚狗蛋 阅读(6) 评论(0) 推荐(0) 编辑
摘要:/** * 冒泡排序 */ public class BubblingSort { public static void main(String[] args) { long[] arr = {45, 34, 23, 12, 1}; sort(arr); for (int i = 0; i < ar 阅读全文
posted @ 2021-12-11 22:34 姚狗蛋 阅读(5) 评论(0) 推荐(0) 编辑
摘要:package com.primary.test; public class Test1 { public static void main(String[] args) { int i = get(3); System.out.println(i); } /** * n的阶乘 */ public 阅读全文
posted @ 2020-09-26 20:35 姚狗蛋 阅读(110) 评论(0) 推荐(0) 编辑
摘要:Node类 //链表结构 public class Node { //数据 public long data; //指针,连接下个结点 public Node next; public Node(long value){ this.data=value; } public void display( 阅读全文
posted @ 2020-03-11 22:17 姚狗蛋 阅读(91) 评论(0) 推荐(0) 编辑
摘要:public class MyStack { private long[] arr; private int top; public MyStack(){ arr = new long[10]; top = -1; } public MyStack(int max){ arr = new long[ 阅读全文
posted @ 2020-03-11 17:39 姚狗蛋 阅读(76) 评论(0) 推荐(0) 编辑
摘要:public class test { public static void main(String[] args) { long[] arr = {45,34,23,12,1}; sort(arr); for (int i = 0; i < arr.length; i++) { System.ou 阅读全文
posted @ 2020-03-11 17:38 姚狗蛋 阅读(87) 评论(0) 推荐(0) 编辑
摘要:public class MyArray { private long[] arr; private int elements;//数组长度 public MyArray(){ arr = new long[50]; } public MyArray(int maxsize){ arr = new 阅读全文
posted @ 2020-03-10 13:06 姚狗蛋 阅读(77) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示