自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(339)
  • 资源 (1)
  • 收藏
  • 关注

原创 O(1) 时间复杂度的抽奖算法 - The Alias Method

使用 Vose‘s Alias Method,我们可以实现初始化为 O(n) 的算法,采样 O(1) 时间复杂度,空间负责度 O(n)。如果抽奖的奖品不考虑库存,那么可以抽奖算法就是 O(1) 事件复杂度。每次考虑库存,抽奖物品的种类变动,直接动态生成即可。

2023-04-14 01:41:07 1104 1

原创 [读书笔记] 重构 - 改善既有代码的设计第二版

refactoring-cheat-sheet《重构 改善既有代码的设计第二版》中文版注意:《重构》书籍中的代码示范,有些展示的不合理,没有与文字解释同步好第 1 章 重构,第一个示例将业务流转逻辑与计算逻辑拆分,简单点说,流转逻辑中使用的计算参数使用计算函数进行拆分出来,消除局部变量。在重构和添加新特性之间寻找平衡。重复的代码片段需要进行提取,抽象成公共的函数,便于维护。代码复审有助于在开发团队中传播知识,也有助于让较有经验的开发者把知识传递给比较欠缺经验的人,并帮助更多人理解大型软件系.

2021-12-02 18:15:36 640

原创 [jsonpath]

JsonPath语法手册

2021-11-12 11:52:04 323

原创 几种对象模型的说明(PO、DTO、VO、BO、DO)

po - persistant object - 持久对象,与实体表一一对应dto - data transfer object - 数据传输对象,其中的数据用于前端展示,可以被vo进行业务转述vo - value object - 值对象,可以根据展示需求对dto中的字段进行删减和业务解释bo - business object - 业务对象,po的组合,可以包含业务的辅助计算数据,dto一般是bo中的一部分do - data object

2021-09-24 11:15:33 416

原创 Framework-golang

Consul 入门基础

2021-08-24 10:46:55 180

原创 go 语言中关于数组值传递的一些疑惑

数组的值传递在 go 语言中数组是一个值类型(value type)所有的值类型变量在赋值和作为参数传递时都将产生一次复制动作。如果将数组作为函数的参数类型,则在函数调用时该参数将发生数据复制。因此,在函数体中无法修改传入的数组的内容,因为函数内操作的只是所传入数组的一个副本func main(){ array := []int{1, 2, 3, 4, 5, 6, 7, 8, 9} fmt.Println("in function main, array values: ", array)

2021-08-10 11:47:22 318 1

原创 [算法题:如何让随机点亮的循环排列的100盏灯全部点亮]

本题来源于一算法同学的面试题第一想到使用数组,因为存在循环排列,觉得构造循环链表更不错,写完感觉可能还是使用数组简洁些/** * 算法题:一个圆环上有100个灯泡,灯泡有打开和关闭两种状态,灯泡的状态随机, * 按一个灯泡的开关,相邻的两个灯泡的状态也发生一次变化。 * 比如暗-亮-暗,按中间灯泡,变化为亮-暗-亮。问设计一道算法,使得所有灯泡最后都亮。 */struct Node { int state; Node* next = nullptr; Node() {}

2021-06-21 19:57:33 366 2

原创 使用 postman 进行测试时,出现没有权限进行访问,需要配置 cookie

step1:点击红框中的 Cookiesstep2:将主域名填写好(比如 https://www.baidu.com),然后点击 Add 按钮step3:点击按钮 Add Cookie,我这边需要去预发(线上)环境拿到 token (token 的形式是:token=xxx;)后复制进去替换第一个框中的内容,然后点击第 2 个框 Save 即可。...

2021-05-18 17:36:27 5209

原创 修改数据库表中字段的时间值

1、修改为特定的时间update tableName set create_time = '2021-05-01 14:00:00' where id = 1;2、修改为15天前的时间update tableNameset create_time = create_time - interval 15 daywhere id = 1;

2021-05-13 14:56:20 2775

原创 C++ 中的 istringstream 流使用

#include <iostream>#include <sstream>using namespace std;int main(int argc, const char * argv[]) { string expression = "2-1-1"; int num = 0; char op = ' '; istringstream is(expression + '+'); while(is >> num &&a

2021-05-11 20:17:06 101

原创 Mysql 将日期和时间拼接起来传入表中 timestamp 类型的字段

- 只会保留 datefield,不管 timefield 是什么,最后数据库中 timefield 都为 00:00:00concat(datefield,' ',timefield) as date- 保留日期和时间concat(datefield,' ',timefield) as date/datetime- 2021-01-01 00:00:00cast(concat('2021-01-01', ' ', '20', ':00:00') as date)- 2021-01-01

2021-05-07 17:01:05 1353

原创 使用python发送复杂邮件

使用python发送邮件# !/usr/bin/python# -*- coding: UTF-8 -*-# 遇到没有执行权限,使用 chmod a+x SendEmail.py import smtplibfrom email.mime.text import MIMETextfrom email.mime.multipart import MIMEMultipartfrom email.utils import formataddrfrom email.mime.image impor

2021-03-04 19:23:26 210 1

原创 [Mac] 为mac自带的QuickTime Player播放器设置快进快退

【step1】点击启动台 -> 点击自动操作【step2】点击快速操作【step3】更改如下输入框内容【step 4】新建快进的AppleScript【step 5】1-复制如下代码片段,2-点小锤子编译on run {input, parameters} set step to 5 tell application "QuickTime Player" if front document exists th...

2020-11-22 23:32:07 5748 10

原创 图文详解KMP算法(C++,Java实现)

KMP整体算法图解:buildMatch算法图解:match[?]:match[match[j-1]]//O(n+m)#include<bits/stdc++.h>using namespace std;//针对pattern字符串建立match数组,match[j]记录从0-j位置能最最大匹配元素的位置ivoid buildMatch(strin...

2020-11-15 16:46:10 2584 6

原创 Android Studio未识别Java文件(出现红J)

随便网上找了一张图片,但问题是一样的,因为Sync完之后,无法截图了!Sync一下Sync完成后全部正常!

2020-11-06 16:05:06 1230

原创 在Mac上配置Android studio的adb

问题:Mac上安装完Android Studio之后,打开终端输入adb,显示没有adb: command not found方法:如下所示// 进入当前用户目录echo $HOME// 创建一个.bash_profile文件(若已经存在此文件,什么都不做)touch .bash_profile// 打开.bash_profile文件open -e .bash_profile/***打开的.bash_profile文件***/···// 文件尾部追加以下环境变量exp

2020-11-03 15:33:42 1410

原创 Using different JDK locations on different processes might cause Gradle to spawn multiple daemon

错误描述Android Studio is using the following JDK location when running Gradle: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home Using different JDK locations on different processes might cause Gradle to spawn multiple daemons, ..

2020-10-27 14:29:29 20174 1

原创 1319. Number of Operations to Make Network Connected

https://leetcode.com/problems/number-of-operations-to-make-network-connected/There arencomputers numbered from0ton-1connected byethernet cablesconnectionsforming a network whereconnections[i] = [a, b]represents a connection between computersa...

2020-10-22 20:21:58 82

原创 1584. Min Cost to Connect All Points [Medium]

https://leetcode.com/problems/min-cost-to-connect-all-points/You are given an arraypointsrepresenting integer coordinates of some points on a 2D-plane, wherepoints[i] = [xi, yi].The cost of connecting two points[xi, yi]and[xj, yj]is themanhatta...

2020-10-22 00:40:41 130 2

原创 不使用额外空间的情况下实现两数交换

基本原理:数字a与数字a异或结果为0。基于此,首先让 a= a ^ b,然后 b= a ^ b= (a ^ b) ^ b = a,最后,a = a ^ b = (a ^ b) ^ a = b(注意原来的b对应现在的a了)。package com.ly.test;public class MyTest { public static void main(String[] args) { int a = -2020; int b = 2020; ...

2020-10-19 15:57:48 270

原创 Java InputStream.read()读取数据流字节,存储到缓冲区数组

定义public abstract int read()public int read(byte[] b)public int read(byte[] b,int off,int len)参数:b:存储读入数据的缓冲区;off:数组 b 中将写入数据的初始偏移量;len:要读取的最大字节数返回:读入缓冲区的总字节数;如果因为已经到达流末尾而不再有数据可用,则返回 -1。异常抛出:IOException: 如果不是因为流位于文件末尾而无法读取第一个字节;如果输入..

2020-10-08 17:50:07 6794

原创 2020-10-08

能出现问题说明:Maven静态资源过滤问题<resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include>

2020-10-08 05:45:06 100

原创 2020-10-08

能出现问题说明:Maven静态资源过滤问题 src/main/java /*.properties /.xml false src/main/resources **/.properties **/*.xml false

2020-10-08 05:43:19 60

原创 2020-10-08

https://pan.baidu.com/s/1iHSjW68zT_FOqOdrNRBemg#list/path=%2F

2020-10-08 00:54:37 61

原创 [Mac] MySQL Community Server 8.0.21 安装

官方下载地址步骤1:下载步骤2:安装下载下来之后直接双击安装可能会出现【无法打开“mysql-8.0.21-macos10.15-x86_64.pkg”,因为Apple无法检查其是否包含恶意软件。】解决方法:设置 - 安全性与隐私接下来一直下一步【注意中间弹出输入密码操作,设置好密码,请记住,后面登陆需要】安装完成后,设置的系统偏好界面下放有个MySQL标志。【启动】点击这标记,勾选Start MySQL when your computer st..

2020-10-07 20:00:20 683

原创 665. Non-decreasing Array [Easy]

https://leetcode.com/problems/non-decreasing-array/Given an arraynumswithnintegers, your task is to check if it could become non-decreasing by modifyingat most1element.We define an array is non-decreasing ifnums[i] <= nums[i + 1]holds for e...

2020-10-04 17:22:41 115

原创 1367. Linked List in Binary Tree [Medium]

https://leetcode.com/problems/linked-list-in-binary-tree/Given a binary treerootand alinked list withheadas the first node.Return True if all the elements in the linked list starting from theheadcorrespond to somedownward pathconnected in the...

2020-10-04 16:38:35 111

原创 380. Insert Delete GetRandom O(1) [Medium]

https://leetcode.com/problems/insert-delete-getrandom-o1/Implement theRandomizedSetclass:bool insert(int val)Inserts an itemvalinto the set if not present. Returnstrueif the item was not present,falseotherwise. bool remove(int val)Removes an...

2020-10-04 04:49:52 125

原创 560. Subarray Sum Equals K [Medium]

https://leetcode.com/problems/subarray-sum-equals-k/Given an array of integers and an integerk, you need to find the total number of continuous subarrays whose sum equals tok.Example 1:Input:nums = [1,1,1], k = 2Output: 2Constraints:The leng..

2020-10-03 23:38:48 110

原创 830. Positions of Large Groups [Easy]

https://leetcode.com/problems/positions-of-large-groups/In a stringsof lowercase letters, these letters form consecutive groups of the same character.For example, a string likes = "abbxxxxzyy"has the groups"a","bb","xxxx","z", and"yy".A gro...

2020-10-03 22:24:12 80

原创 229. Majority Element II [Medium]

https://leetcode.com/problems/majority-element-ii/Given an integer array of sizen, find all elements that appear more than⌊ n/3 ⌋times.Follow-up:Could you solve the problemin linear time and in O(1) space ?Example 1:Input: nums = [3,2,3]Outp...

2020-10-03 01:38:26 66

原创 1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree [Medium]

https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/Given two binary treesoriginalandclonedand given a reference to a nodetargetin the original tree.Theclonedtree is acopy oftheoriginaltree.Ret...

2020-10-03 00:19:42 113

原创 1110. Delete Nodes And Return Forest [Medium]

https://leetcode.com/problems/delete-nodes-and-return-forest/submissions/Given therootof a binary tree, each node in the tree has a distinct value.After deletingall nodes with a value into_delete, we are left with a forest (adisjoint union of tree...

2020-10-02 18:50:39 130

原创 998. Maximum Binary Tree II [Medium]

https://leetcode.com/problems/maximum-binary-tree-ii/We are given therootnode of amaximum tree:a tree where every node has a value greater than any other value in its subtree.Just as in theprevious problem, the given treewas constructed from an l...

2020-10-01 23:23:37 55

原创 1145. Binary Tree Coloring Game [Medium]

https://leetcode.com/problems/binary-tree-coloring-game/Two players play a turn based game on a binary tree. We are giventherootof this binary tree, and the number of nodesnin the tree.nis odd, andeach node has a distinct value from1ton.In...

2020-10-01 22:06:02 81

原创 695. Max Area of Island [Medium]

https://leetcode.com/problems/max-area-of-island/Given a non-empty 2D arraygridof 0's and 1's, anislandis a group of1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded ...

2020-10-01 17:51:31 66

原创 971. Flip Binary Tree To Match Preorder Traversal [Medium]

https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal/Given a binary tree withNnodes, each node has a different value from{1, ..., N}.A node in this binary tree can beflippedby swapping the left child and the right child of th...

2020-10-01 17:22:21 113

原创 1123. Lowest Common Ancestor of Deepest Leaves [Medium]

https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/Given a rooted binary tree, return the lowest common ancestor of its deepest leaves.Recall that:The node of a binary tree is aleafif and only if it has no children Thedepthof...

2020-10-01 14:34:30 94

原创 1325. Delete Leaves With a Given Value [Medium]

https://leetcode.com/problems/delete-leaves-with-a-given-value/Given a binary treerootand an integertarget, delete all theleaf nodeswith valuetarget.Notethat once you delete a leaf node with valuetarget,if it's parent node becomes a leaf node ...

2020-10-01 03:56:24 92

原创 979. Distribute Coins in Binary Tree [Medium]

979. Distribute Coins in Binary Tree [Medium]Given the root of a binary tree with N nodes, each node in the tree has node.val coins, and there are N coins total.In one move, we may choose two adjacent nodes and move one coin from one node to another. (T

2020-10-01 01:04:09 71

计算机操作系统.xmind

计算机操作系统.xmind

2021-05-20

空空如也

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

TA关注的人

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