Skip to content

Instantly share code, notes, and snippets.

@smallyunet
smallyunet / ListNode.java
Last active November 4, 2019 03:28
Building a singly linked list
/**
* @description Unidirectional linked data structure
* @author smallyu
* @date 2019/10/23 13:22
*/
public class ListNode {
int val;
ListNode next;
ListNode(int x) {
val = x;
@smallyunet
smallyunet / TreeNode.java
Last active November 4, 2019 03:31
Build a sequence binary tree through an array
/**
* @description Sequence binary tree structure
* @author smallyu
* @date 2019/11/4 10:20
*/
class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x) { val = x; }
@smallyunet
smallyunet / getCharCountByVar.js
Created March 17, 2020 10:29
get character total number by ...
/**
* @param Array
* @return Map
*/
var getCharNumByArray = (arr) => {
var m = new Map()
arr.map(i => {
if (m.get(i) == undefined) {
m.set(i, 1)
} else {
@smallyunet
smallyunet / sumByString.py
Last active March 25, 2020 12:07
get sum by two string
"""
@desc get sum by two string
@param string s1
@param string s2
@return string
"""
def sumByString(s1, s2):
s1 = s1.rjust(len(s2), '0')
s2 = s2.rjust(len(s1), '0')
@smallyunet
smallyunet / quickSort.py
Last active March 25, 2020 12:08
quick sort by python
"""
@desc quick sort python version
@param List arr
@return List arr
"""
def quickSort(arr, left=None, right=None):
# default parameter
if left == None or right == None:
left = 0
@smallyunet
smallyunet / generatorIdNumber.js
Created May 15, 2020 07:13
身份证号码校验位的校验算法
// 验证身份证号码的算法
// 可以根据规则找出校验位合规的身份证号
let generatorIdNumber = (x) => {
// 目前是 16位 + 2位
let str = '1111111111111111' + x
// 字符值
let a = str.split('').map(i => parseInt(i))
// 权重银子
docker-shortcut
sonatype.bookmark
daily-issue.bookmark
chrome-bookmark-archive