![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
algorithm
coderlong
钱能解决的事情,,,我都解决不了。
展开
-
leetcode453_Minimum_moves_to_Equal_array
title: stringComplare date: 2017-10-26 21:00:54 categories: - java tags: - JVM - java摘要: 探秘String Stringbuffer StrignBuilder你了解String 类吗?想要了解一个类,最好的办法就是看这个类的实现源代码,String类的实现在 \jdk1.6.0原创 2017-12-18 23:07:10 · 172 阅读 · 0 评论 -
数值的整数次方
title: 数值的整数次方 date: 2018-3-1 14:18:40 categories: - 剑指offer tags: - Algorithm - 剑指offer数值的整数次方题目描述: 输入一个链表,从尾到头打印链表每个节点的值。public class 从尾到头打印链表 { public static v...原创 2018-03-08 19:52:04 · 180 阅读 · 0 评论 -
打印1到最大的n位数
title: 打印1到最大的n位数 date: 2018-3-1 14:18:40 categories: - 剑指offer tags: - Algorithm - 剑指offer打印1到最大的n位数 题目描述:如n=3,则从1打印到999public class 打印1到最大的N位数 { public static vo...原创 2018-03-08 19:52:22 · 216 阅读 · 0 评论 -
在O(1)时间删除链表结点
title: 在O(1)时间删除链表结点 date: 2018-3-1 14:18:40 categories: - 剑指offer tags: - Algorithm - 剑指offer在O(1)时间删除链表结点题目描述: 给定单向链表头指针和一个节点指针,在O(1)时间删除链表结点/*** @author 作者 : coder...原创 2018-03-08 19:52:38 · 201 阅读 · 0 评论 -
调整数组顺序使奇数位于偶数前面
title: 调整数组顺序使奇数位于偶数前面 date: 2018-3-1 14:18:40 categories: - 剑指offer tags: - Algorithm - 剑指offer调整数组顺序使奇数位于偶数前面题目描述 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于位于数...原创 2018-03-08 19:52:54 · 133 阅读 · 0 评论 -
Silent-moon
title: Silent moon date: 2017-10-26 21:00:54 categories: - 生活 tags: - moon - 生活 - algorithm摘要: 很久没见到月亮了 大数问题 以前做过一道,求2的几百次方的大数运算,用的字符数组存储大数的每一位 Java就更加方便了,有专门的解...原创 2018-03-16 14:23:12 · 137 阅读 · 0 评论 -
ZigZagTree
title: ZigZagTree date: 2017-11-13 19:33:49 categories: - algorithm tags: - java - algorithm摘要: Binary Tree Level Order Traversal Given a binary tree, return the zigzag leve...原创 2018-03-16 14:23:44 · 216 阅读 · 0 评论 -
几种排序算法
title: 几种排序算法 date: 2018-3-13 19:18:40 categories: - Algorithm tags: - Algorithm插入排序public class 插入排序 { public static void main(String[] args) { // TODO Auto-genera...原创 2018-03-16 14:24:46 · 112 阅读 · 0 评论 -
异或去重
title: 异或去重 date: 2018-02-21 22:32:55 —categories: - Algorithm tags: - Algorithm来看三道题目 1、1-1000放在含有1001个元素的数组中,只有唯一的一个元素值重复,其它均只出现一次。每个数组元素只能访问一次,设计一个算法,将它找出来;不用辅助存储空间,能否设计一个算法实现?...原创 2018-03-05 19:57:43 · 919 阅读 · 0 评论 -
非递归中序遍历的一点解释
递归形式的前序,中序,后序,便利大家应该都是比较熟悉的。但是,有时候,在针对一些对BST遍历过程中节点状态控制的时候,使用非递归形式的算法,往往更加有效,代码更加简洁。 1. 先把二叉树的非递归中序遍历贴出。leetcode题目public List<Integer> inorderTraversal(TreeNode root) { List<Integer>...原创 2018-04-16 16:54:30 · 592 阅读 · 0 评论 -
HeapSort
title: 记一次堆排序 date: 2018-4-5 10:13:40 categories: - algorithm tags: - algorithm摘要作为选择排序的改进版,堆排序可以把每一趟元素的比较结果保存下来,以便我们在选择最小/大元素时对已经比较过的元素做出相应的调整。 堆排序是一种树形选择排序,在排序过程中可以把元素看成是一颗完全...原创 2018-04-11 15:03:35 · 243 阅读 · 0 评论 -
硬币组合
title: 硬币组合 date: 2018-4-5 10:12:40 categories: - algorithm tags: - algorithm问题给定一个数值sum,假设我们有m种不同类型的硬币{V1, V2, …, Vm},如果要组合成sum,求所有可能的组合数。 给定一个数值sum,假设我们有m种不同类型的硬币{V1, V2, …, ...原创 2018-04-11 15:03:55 · 1653 阅读 · 0 评论 -
回溯算法的一点总结
title: backtrack解决问题一点总结date: 2018-2-5 21:18:40categories:- Algorithmtags:- Algorithm算法设计与分析中就学过回溯法(递归,迭代),可是一遇到问题,还是没有建立起使用回溯的思想。在子集包含,字符串重建,序列,等问题中都非常好用。Permutations1public class leetcod...原创 2019-06-05 19:42:43 · 2297 阅读 · 0 评论 -
滑动窗口最大值
title: 滑动窗口最大值date: 2018-3-6 14:18:40categories:- 剑指offertags:- Algorithm- 剑指offer给定一个数组和滑动窗口的大小,请找出所有滑动窗口里的最大值。代码实现public class 滑动窗口的最大值 { public ArrayList<Integer> maxInWindows(int ...原创 2019-06-05 19:44:38 · 1455 阅读 · 0 评论 -
Raft算法的Java实现
自己这几天在学习Redis的Sentinel高可用解决方案,Sentinel选主使用的是著名的Raft一致性算法,本文对Raft的选主作了介绍,具体的算法内容,请参考 Raft 英文PaperRaft的整体结构Raft 通过选举一个高贵的领导人,然后给予他全部的管理复制日志的责任来实现一致性。而每个 server 都可能会在 3 个身份之间切换:领导者候选者跟随者而影响他们身份...原创 2019-06-06 11:29:20 · 13030 阅读 · 7 评论 -
Dubbo中几种负载均衡方式
AbstractLoadBalanceDubbo 中,所有负载均衡实现类均继承自 AbstractLoadBalance,该类实现了 LoadBalance 接口,并封装了一些公共的逻辑。如下 public <T> Invoker<T> select(List<Invoker<T>> invokers, URL url, Invocation ...原创 2019-07-21 18:24:41 · 1356 阅读 · 0 评论 -
斐波那契数列
title: 斐波那契数列 date: 2018-3-1 14:18:40 categories: - 剑指offer tags: - Algorithm - 剑指offer给定一个数组和滑动窗口的大小,请找出所有滑动窗口里的最大值。斐波那契数列题目描述 大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项。...原创 2018-03-08 19:51:47 · 174 阅读 · 0 评论 -
LinkedHashMap源码剖析
title: LinkedHashMap源码剖析 date: 2018-3-8 23:18:40 categories: - JDK tags: - JDK - 代码重构 - 源码学习前面分析了HashMap的实现,我们知道其底层数据存储是一个hash表(数组+单向链表)。接下来我们看一下另一个LinkedHashMap,它是HashMap...原创 2018-03-08 19:51:31 · 125 阅读 · 0 评论 -
二叉树的最小深度
求一棵树的最小深度我在这里给出了三种语言的解法。 Java versionpublic int minDepth(TreeNode root) { if (root == null) return 0; int L = minDepth(root.left), R = minDepth(root.right); return 1 + (Math.min(L, R) > 0原创 2018-01-05 11:19:25 · 198 阅读 · 0 评论 -
538. Convert BST to Greater Tree
题目 Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST. Exa原创 2018-01-05 22:10:26 · 156 阅读 · 0 评论 -
约瑟夫环问题
第一次参加CCF的时候,也想用linkedList来实现这个来着,可惜当时时间紧张,最后还是强行写了一个双向循环链表 最后 一个一个的删除元素,这样的利用原理来实现是最简单简洁的 “` public class 约瑟夫环 {public static void main(String[] args) { // TODO Auto-generated method stub y原创 2018-01-06 22:29:11 · 169 阅读 · 0 评论 -
leetcode551_Student_Attendance_Record1
学生出勤记录You are given a string representing an attendance record for a student. The record only contains the following three characters:'A' : Absent.'L' : Late.'P' : Present.A student could be rewarde原创 2018-01-09 11:36:37 · 144 阅读 · 0 评论 -
Max Sum of Rectangle No Larger Than K
title: 363.Max Sum of Rectangle No Larger Than K date: 2018-2-7 21:48:38 categories: - algorithm tags: - algorithm - java - leetcodeGiven a non-empty 2D matrix matrix and an原创 2018-02-07 21:30:53 · 179 阅读 · 0 评论 -
leetcode023_Generate_Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ “((()))”, “(()())”, “(())()”, “()(())”,原创 2018-03-07 16:31:45 · 144 阅读 · 0 评论 -
AVL平衡树详解
title: AVL平衡树删除增加操作 date: 2018-3-7 23:59:17 categories: - java tags: - java - java集合 - JDK在看MySQL索引结构的时候,就对什么B树,B+树,BST有点混淆了。 等到在遇到AVL树,JDK的HashMap实现红黑树的时候,就更加搞不明白了, 所以...原创 2018-03-07 19:38:16 · 263 阅读 · 0 评论 -
二维数组查找
题目描述 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。·思路: 从右上角开始,若小,向下走,删除一行,若大,向左走,删除一列/*** @author 作者 : coderlong* @version 创建时间:2018年2月8日 下午9:44:23* 类说明...原创 2018-03-08 18:57:02 · 124 阅读 · 0 评论 -
二维数组查找
title: 二维数组查找 date: 2018-3-6 14:18:40 categories: - 剑指offer tags: - Algorithm - 剑指offer题目描述 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。...原创 2018-03-08 19:48:50 · 111 阅读 · 0 评论 -
替换空格
title: 替换空格 date: 2018-3-6 14:18:40 categories: - 剑指offer tags: - Algorithm - 剑指offer题目描述 请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。先遍历一遍字...原创 2018-03-08 19:49:25 · 142 阅读 · 0 评论 -
重建二叉树
title: 重建二叉树 date: 2018-3-6 14:18:40 categories: - 剑指offer tags: - Algorithm - 剑指offer重建二叉树题目描述:已知中序和前序,请重建二叉树public class 二叉树重建 { public static void main(String[...原创 2018-03-08 19:49:46 · 157 阅读 · 0 评论 -
用两个栈实现队列
title: 用两个栈实现队列 date: 2018-3-6 14:18:40 categories: - 剑指offer tags: - Algorithm - 剑指offer用两个栈实现队列题目描述 用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。public class 两个栈实现队列 {...原创 2018-03-08 19:50:06 · 135 阅读 · 0 评论 -
旋转数组的最小数字
title: 旋转数组的最小数字 date: 2018-3-6 14:18:40 categories: - 剑指offer tags: - Algorithm - 剑指offer旋转数组的最小数字题目描述 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个递增排序的数组的一个旋转,输出旋转数组的最小元素。 例...原创 2018-03-08 19:50:27 · 127 阅读 · 0 评论 -
二进制中1的个数
title: 二进制中1的个数 date: 2018-3-6 14:18:40 categories: - 剑指offer tags: - Algorithm - 剑指offer 二进制中1的个数 题目描述 输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。public class 二进制1的个数 { pu...原创 2018-03-08 19:50:44 · 136 阅读 · 0 评论 -
从尾到头打印链表
title: 从尾到头打印链表 date: 2018-3-1 14:18:40 categories: - 剑指offer tags: - Algorithm - 剑指offer从尾到头打印链表题目描述: 输入一个链表,从尾到头打印链表每个节点的值。public class 从尾到头打印链表 { public static...原创 2018-03-08 19:51:01 · 122 阅读 · 0 评论 -
Consistent Hash Algorithms
哈哈, 代码是最好的注释,原创 2019-08-12 23:07:22 · 151 阅读 · 0 评论