- 博客(284)
- 收藏
- 关注
原创 Paxos 算法分析
Paxos 的核心思想:“与其预测未来,不如限制未来”。背景:Paxos算法是莱斯利·兰伯特(英语:Leslie Lamport,LaTeX中的“La”)于1990年提出的一种基于消息传递且具有高度容错特性的共识(consensus)算法。分布式系统中的节点通信存在两种模型:共享内存(Shared memory)和消息传递(Messages passing)。基于消息传递通信模型的分布式系统,不可避免的会发生以下错误:进程可能会慢、被杀死或者重启,消息可能会延迟、丢失、重复,在基础 .
2020-07-22 20:03:53 367
原创 并查集算法(Union find)第二式:加权quick-union
参考: 《算法》第四版,p144- p146以leetcode, 200th : Number of Islands() 为例 (https://leetcode.com/problems/number-of-islands/)对于加权quick-union算法,N个触点,在最坏情况下,find()、union()、isConnected()的成本增长数量级为lgNpackage...
2020-03-31 18:49:34 224
原创 并查集算法(Union find)第一式:quick-union
参考: 《算法》第四版,p136 - p144以leetcode, 200th : Number of Islands() 为例 (https://leetcode.com/problems/number-of-islands/)package com.odyssey.app.algorithm.base;/** * 并查集算法 - 以lc200,number of island...
2020-03-29 16:59:21 198
原创 JVM - 老年代垃圾收集器CMS产生的问题分析
Concurrent Mark Sweep 垃圾收集器,GC 过程中不可避免的问题:1、 promotion failed2、concurrent mode failureGC 日志举例:106.641: [GC 106.641: [ParNew (promotion failed): 14784K->14784K(14784K), 0.0370328 secs]106...
2019-10-30 20:14:38 628
原创 Snowflake 算法分析与Java实现(参考 Twitter 官方 Scala 原版实现)
参考:Twitter 官方 Scala 原版实现https://github.com/twitter-archive/snowflakepackage com.app.main.snowflake;/** * Created with IDEA * author:Dingsheng Huang * Date:2019/8/4 * Time:下午4:28 * *...
2019-08-04 17:48:31 257
转载 SDE的核心能力-抽象思维
新技术变化太快,稍不留意就陷入了追逐乱七八糟技术的泥潭中,还洋洋得意的认为自己在持续学习,然而实际上并没有沉淀出有意义的东西,切忌多思考价值.程序员要掌握的知识,要具备的能力实在太多,多得头发都不够掉。大体有两大方向。一是对工具的熟练掌握,如操作系统、网络、IO、编程语言等;另一个是用代码为现实问题生成解决方案的能力,这其中最重要的是抽象能力。前一个方向是很容易意识到的,很多现象可以说...
2019-04-28 21:10:08 443
原创 LeetCode--medium--interleaving_string_97
summary:divide and conquer | memorizationpackage myapp.kit.leetcode.top200;import java.util.HashMap;import java.util.Map;/** * * 97 * hard * https://leetcode.com/problems/interleaving-string/ * * Given s1, s2, s3, find whether s3 is formed
2020-07-22 19:45:11 285
原创 LeetCode--medium--valid_number_65
summary:DFApackage myapp.kit.leetcode.top200;import java.util.HashMap;import java.util.HashSet;import java.util.Map;import java.util.Set;/** * * 65 * hard * https://leetcode.com/problems/valid-number/ * * Validate if a given string can be
2020-07-22 19:43:32 270
原创 LeetCode--medium--search_in_rotated_array_ii_81
summary:binary searchpackage myapp.kit.leetcode.top200;/** * 81 * medium * https://leetcode.com/problems/search-in-rotated-sorted-array-ii/ * * Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. * *
2020-07-22 19:40:52 154
原创 LeetCode--medium--scramble_string_87
summary:divide and conquer | memorizationpackage myapp.kit.leetcode.top200;import java.util.HashMap;import java.util.Map;/** * 87 * hard *https://leetcode.com/problems/scramble-string/ * * Given a string s1, we may represent it as a binary
2020-07-22 19:39:53 133
原创 LeetCode--medium--rotate_list_61
summary:two pointerspackage myapp.kit.leetcode.top200;import myapp.kit.leetcode.base.ListNode;/** * * 61 * medium * https://leetcode.com/problems/rotate-list/ * * Given a linked list, rotate the list to the right by k places, where k is non-
2020-07-22 19:37:47 156
原创 LeetCode--medium--remove_duplicates_from_sorted_list_83
summary:linked listpackage myapp.kit.leetcode.top200;import myapp.kit.leetcode.base.ListNode;/** * 83 * easy *https://leetcode.com/problems/remove-duplicates-from-sorted-list/ * * Given a sorted linked list, delete all duplicates such that ea
2020-07-20 11:12:17 226
原创 LeetCode--medium--remove_duplicates_from_sorted_list_82
summary:linked listpackage myapp.kit.leetcode.top200;import myapp.kit.leetcode.base.ListNode;/** * 82 * medium * https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ * * Given a sorted linked list, delete all nodes that have d
2020-07-20 11:11:20 108
原创 LeetCode--medium--remove_duplicates_from_sorted_array_ii_80
summary:arraypackage myapp.kit.leetcode.top200;/** * * * 80 * medium * https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/ * * Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most t
2020-07-20 11:10:31 224
原创 LeetCode--medium--permutation_sequence_60
/** * summary: * approach 1 : dfs backtrack but TLE ! * * approach 2 : math * candidate: [1,2,3,4,...n] kth * 1. calculate block size : (n - 1)! * 2. renew candidate and k * new k = k % (n - 1)! * .
2020-07-20 11:08:30 127
原创 LeetCode--medium--partition_list_86
summary:divide and conquer | two pointerspackage myapp.kit.leetcode.top200;import myapp.kit.leetcode.base.ListNode;/** * * 86 * medium * https://leetcode.com/problems/partition-list/ * * * Given a linked list and a value x, partition it suc
2020-07-20 11:05:57 112
原创 LeetCode--medium--n_queens_ii_52
summary:backtrackpackage myapp.kit.leetcode.top200;import java.util.ArrayList;import java.util.List;/** * * 52 * hard * https://leetcode.com/problems/n-queens-ii/ * * The n-queens puzzle is the problem of placing n queens on an n×n chessboa
2020-07-20 11:04:50 231
原创 LeetCode--medium--n_queens_51
summary:backtrackpackage myapp.kit.leetcode.top200;import java.util.ArrayList;import java.util.List;/** * * 51 * hard *https://leetcode.com/problems/n-queens/ * The n-queens puzzle is the problem of placing n queens on an n×n chessboard such
2020-07-20 11:03:50 124
原创 LeetCode--medium--multiply_strings_43
summary:handle carrypackage myapp.kit.leetcode.top200;/** * 43 * medium * https://leetcode.com/problems/multiply-strings/ * * Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, * also rep
2020-07-20 11:02:55 156
原创 LeetCode--medium--combinations_77
summary:combinations | backtrackpackage myapp.kit.leetcode.top200;import java.util.ArrayList;import java.util.List;/** * * 77 * medium * https://leetcode.com/problems/combinations/ * * Given two integers n and k, return all possible combina
2020-07-20 11:01:42 129
原创 LeetCode--medium--add_binary_67
summary:handle carrypackage myapp.kit.leetcode.top200;/** * * 67 * medium * https://leetcode.com/problems/add-binary/ * * Given two binary strings, return their sum (also a binary string). * * The input strings are both non-empty and contain
2020-07-20 11:00:31 104
原创 Java map 优雅的元素遍历方式
Java 8 , Lambda + foreach 语法糖, 写起来非常的 cleanpublic static void main(String[] args) { // map init Map<String, String> map = new HashMap<>(); map.put("k", "v"); /*=====处理函数只有单条语句=====*/ map.forEach((k...
2020-07-03 17:32:17 819
原创 LeetCode--12--medium--IntegerToRoman
summary:classified discussionpackage myapp.kit.leetcode.top200;/** * 12 * medium * https://leetcode.com/problems/integer-to-roman/ * * Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. * * Symbol Value
2020-06-29 21:40:56 139
原创 mysql 按天、周、月分组查询【sql模板】
1. 按天统计: select DATE_FORMAT(create_time, '%Y%m%d') days, count(id) from xxx_table group days;2. 按周统计: select DATE_FORMAT(create_time,'%Y%u') weeks,count(id) fromxxx_table group by weeks; 3. 按月统计 select DATE_FORMAT(create_time,...
2020-06-29 21:26:55 996
原创 mysql 日期与时间戳转换【sql 模板】
1.日期 ---> 时间戳(秒)selectUNIX_TIMESTAMP('2020-07-01 12:00:00')输出:15935760002. 时间戳 (秒)---> 日期select FROM_UNIXTIME(1593576000)输出:2020-07-01 12:00:00
2020-06-28 11:04:55 342
原创 mysql查询字段长度 | length()、char_length()函数说明
1. MySQL5.0.3版本之后varchar类型的变化 1)、MySQL 5.0.3 之前:0-255字节,如:varchar(20)中的20表示字节数,如果存放utf-8编码的话只能放6个汉字。varchar(n),这里的n表示字节数。 MySQL 5.0.3 之后:0-65535字节,varchar(20)表示字符数,不管什么编码,既汉字也能放20个。但最多占65532字节(两个字节存放长度,小于255字节用1个字节存放长度),varchar(n)这里的n表示字符数,比如varchar
2020-06-22 21:58:47 12742
原创 LeetCode--6--medium--ZigZagConversion
summary:calculatepackage myapp.kit.leetcode.top200;/** * 6 * medium * https://leetcode.com/problems/zigzag-conversion/ * * The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display
2020-06-22 10:50:10 143
原创 LeetCode--127--medium--WordLadder
summary:bfspackage myapp.kit.leetcode.top145;import java.util.ArrayList;import java.util.HashSet;import java.util.List;import java.util.Set;/** * * 127 * medium * https://leetcode.com/problems/word-ladder/ * * * Given two words (beginWor
2020-06-22 10:48:35 107
原创 LeetCode--140--hard--WordBreakII
summary:memorizationpackage myapp.kit.leetcode.top145;import java.util.ArrayList;import java.util.HashMap;import java.util.HashSet;import java.util.List;import java.util.Map;import java.util.Set;/** * 140 * hard * https://leetcode.com/prob
2020-06-22 10:47:06 124
原创 LeetCode--44--hard--WildcardMatching
summary:memorization cache | dynamic programpackage myapp.kit.leetcode.top145;/** * * 44 * hard * https://leetcode.com/problems/wildcard-matching/ * * Given an input string (s) and a pattern (p), implement wildcard pattern matching with suppo
2020-06-21 20:28:30 163
原创 LeetCode--680--easy--ValidPalindromeII
summary:two pointerspackage myapp.kit.leetcode.top145;/** * * 680 * easy * https://leetcode.com/problems/valid-palindrome-ii/ * *Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. *
2020-06-21 20:15:58 146
原创 LeetCode--125--easy--ValidPalindrome
summary:two pointerspackage myapp.kit.leetcode.top145;/** * * 125 * easy *https://leetcode.com/problems/valid-palindrome/ * * * Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. *
2020-06-21 20:14:32 167
原创 LeetCode--37--hard--SudokuSolver
summary:dfs search | backtrackpackage myapp.kit.leetcode.top145;import java.util.HashSet;import java.util.Set;/** * * 37 * hard * https://leetcode.com/problems/sudoku-solver/ * * Write a program to solve a Sudoku puzzle by filling the empt.
2020-06-21 20:13:02 180
原创 LeetCode--73--medium--SetMatrixZeroes
summary:hash tablepackage myapp.kit.leetcode.top145;import java.util.HashSet;import java.util.Set;/** * * 73 * medium * https://leetcode.com/problems/set-matrix-zeroes/ * * Given a m x n matrix, if an element is 0, set its entire row and co
2020-06-21 20:11:10 165
原创 LeetCode--50--medium--Pow
summary:divide and conquerpackage myapp.kit.leetcode.top145;/** * * 50 * medium * https://leetcode.com/problems/powx-n/ * * Implement pow(x, n), which calculates x raised to the power n (xn). * * Example 1: * * Input: 2.00000, 10 * Output
2020-06-21 20:10:17 139
原创 LeetCode--131--medium--PalindromePartitioning
summary:dfs search | memorization cachepackage myapp.kit.leetcode.top145;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;/** * * 131 * medium * https://leetcode.com/problems/palindrome-partitio
2020-06-21 20:08:52 112
原创 LeetCode--134--medium--GasStation
summary:dfs search | greedy (todo)package myapp.kit.leetcode.top145;/** * * 134 * medium * https://leetcode.com/problems/gas-station/ * * There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. * * Yo
2020-06-21 20:07:16 109
原创 LeetCode--91--medium--DecodeWays
summary:dynamic programpackage myapp.kit.leetcode.top145;import java.util.HashMap;import java.util.Map;/** * * 91 * medium *https://leetcode.com/problems/decode-ways/ * * A message containing letters from A-Z is being encoded to numbers usi
2020-06-21 20:05:01 1336
原创 LeetCode--224--hard--BasicCalculator
summary:stack | infix expression - > prefixpackage myapp.kit.leetcode.top145;import java.util.Stack;/** * * 224 * hard * https://leetcode.com/problems/basic-calculator/ * * Implement a basic calculator to evaluate a simple expression str.
2020-06-21 20:02:59 145
原创 堆排序标准实现及时间复杂度分析
package myapp.kit.quickstart.utils;import java.util.Arrays;/** * @author huangdingsheng * @version 1.0, 2020/6/15 */public class HeapSort { public static void sort(int[] arr) { int len = arr.length; int startIdx = len / 2 - 1;.
2020-06-15 16:07:18 266
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人