自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(571)
  • 收藏
  • 关注

原创 双指针问题

华为OD 004] 完美走位。

2023-01-05 22:19:10 172

原创 [华为OD 004] 完美走位

输入一个长度为4的倍数的字符串Q,字符串中仅包含WASD四个字母。将这个字符串中的连续子串用同等长度的仅包含WASD的字符串替换,如果替换后整个字符串中WASD四个字母出现的频数相同, 那么我们称替换后的字符串是“完美走位”。求子串的最小长度。如果输入字符串已经平衡则输出0。输入: 一行字符表示给定的字符串S数据范围: 1

2023-01-05 21:19:32 3102 8

原创 Function ‘MseLossBackward0‘ returned nan values in its 0th output.

这个比较奇怪的提示来自于Pytorch计算梯度的过程中产生了一个nan值。如果开启了:torch.autograd.set_detect_anomaly(True)那么在loss.backward()的时候就会出现这个提示。为什么会出现这的情况呢?在pytorch的一个讨论中出现过这个问题,链接:https://discuss.pytorch.org/t/function-mselossbackward-returned-nan-values-in-its-0th-output/94875。讨

2022-03-15 11:33:48 6402

原创 逻辑回归简介

逻辑回归模型(Logistic regression,LR),又称对数几率模型。由于逻辑回归模型简单,可解释强,易实现,广泛应用于机器学习、深度学习、推荐系统、广告预估、智能营销、金融风控、社会学、生物学、经济学等领域[1]。基础逻辑函数逻辑回归中的逻辑,就是指逻辑函数。至于为什么叫做逻辑函数,其提出者韦吕勒并没有给出明确的解释,后人推断这个词的来源是希腊语λογῐστῐκός(logistikos),意为“算术”或“实用数学”,以与对数曲线(logarithmic)区分[4]。逻辑回归的函数如下所

2022-03-15 10:43:23 2051

原创 《The Go Programming Language》推荐理由

  《The Go Programming Language》,中文翻译为《Go语言圣经》[1],是学习Go语言极为推荐的入门读物。理由如下:案例丰富。从最简单的hello world到复杂的反射,都有详细的案例。行文生动。书中的用语简练生动,常常看到幽默的表达,如书中第100页中一个例子中写道:dilbert.Salary -= 5000 // demoted, for writing too few lines of code内容详实。因为本书的作者有亲身参与到Go语言的设计和实现,所

2021-11-12 20:40:33 376

原创 分布式一致性算法简介

文章目录基础理论ACIDAtomic 原子性Consistency 一致性Isolation 隔离性Durability 持久性CAPConsistency 一致性Availability 可用性Partition tolerance 分区容错性BASEBasically Available 基本可用Soft state 软状态Eventually consistent 最终一致性分布式一致性算法时间戳和向量时钟时间戳向量时钟2PC阶段1 提交事务请求,即投票阶段阶段2 执行事务提交,即执行阶段优缺点3PC

2021-11-08 09:55:38 1734

原创 vscode 升级到1.58.*后不能使用Remote-SSH

reference:-githubhttps://github.com/microsoft/vscode-remote-release/issues/4743-stackoverflowhttps://stackoverflow.com/questions/56671520/how-can-i-install-vscode-server-in-linux-offline造成这个问题的原因有两个,一是远端不能正确的下载vscode-server-linux-x64.tar.gz,二是未...

2021-07-16 15:02:50 2196

原创 LeetCode515. Find Largest Value in Each Tree Row

Given therootof a binary tree, returnan array of the largest value in each rowof the tree(0-indexed).Example 1:Input: root = [1,3,2,5,3,null,9]Output: [1,3,9]Example 2:Input: root = [1,2,3]Output: [1,3]Example 3:Input: root = ...

2021-06-30 22:21:19 79

原创 LeetCode514. Freedom Trail

In the video game Fallout 4, the quest"Road to Freedom"requires players to reach a metal dial called the"Freedom Trail Ring"and use the dial to spell a specific keyword to open the door.Given a stringringthat represents the code engraved on the out...

2021-06-30 22:10:08 83

原创 LeetCode513. Find Bottom Left Tree ValueMedium

Given therootof a binary tree, return the leftmost value in the last row of the tree.Example 1:Input: root = [2,1,3]Output: 1Example 2:Input: root = [1,2,3,4,null,5,6,null,null,7]Output: 7Constraints:The number of nodes in the t..

2021-06-30 22:08:11 59

原创 LeetCode509. Fibonacci Number

TheFibonacci numbers, commonly denotedF(n)form a sequence, called theFibonacci sequence, such that each number is the sum of the two preceding ones, starting from0and1. That is,F(0) = 0, F(1) = 1F(n) = F(n - 1) + F(n - 2), for n > 1.Given...

2021-06-30 22:05:49 71

原创 关于二叉树非递归后续遍历的一些思考

我们知道,在二叉树的三种遍历方式中,非递归的后续遍历是最难的,但是一个偶然的发现让我觉得二叉树的后序遍历也没有那么难。发生这样转换的关键在于反向思维,具体讲解如下。以下面的二叉树为例讲解这个问题。有二叉树如上所示,其前序遍历为:1 2 4 7 3 5 6 8其后序遍历为:7 4 2 5 8 6 3 1如果我们将后续遍历反过来看(暂时称为反后序遍历),其遍历的顺序为:1 3 6 8 5 2 4 7看出来什么问题没有?其实反后序遍历和前序遍历是一样的,唯一的区别是,前序

2021-05-23 14:41:52 149

原创 LeetCode 508. Most Frequent Subtree Sum

Given therootof a binary tree, return the most frequentsubtree sum. If there is a tie, return all the values with the highest frequency in any order.Thesubtree sumof a node is defined as the sum of all the node values formed by the subtree rooted at...

2021-05-16 16:33:16 66

原创 LeetCode 507. Perfect Number

Aperfect numberis apositive integerthat is equal to the sum of itspositive divisors, excluding the number itself. Adivisorof an integerxis an integer that can dividexevenly.Given an integern, returntrueifnis a perfect number, otherwise re...

2021-05-05 17:49:55 99

原创 做一个长期主义者

复利据说被爱因斯坦称作世界第八奇迹,那它能创造多大的奇迹?看看复利的代理人巴菲特就知道了。关于复利的一个经典应用就是1%定律,如果一个人每天进步1%,那么一年之后能够进步30多倍。而想要借用复利的力量,重点不在于显著的进步,而是长期的坚持,成为时间的伙伴。罗振宇说:只有长期主义者,才能成为时间的伙伴。积少成多,积沙成塔的道理大家都懂,但是能够长期坚持的人却很少(陋习除外)。去除意志力薄弱等主观因素,恰当的方法也很重要。如何能够长期专注于某事,并且持之以恒地做下去呢?下面给出了三条建议。1 确立目标

2021-04-28 09:55:48 310 1

原创 the elements of Go coding

在读研阶段,学习英语写作的缘故接触了《the elements of style》,该书被奉为英文写作的必读指南,非常精简。虽然书中的具体语法现已遗忘许多,但其核心思想却一直印象深刻,总结一下就是:化繁为简。为了提升代码规范,最近阅读了相关书籍《clean code》,该书是针对Java编写的,所以针对Java的一些规范,比如类相关的内容就略过了,但这本书的核心思想对Go也同样适用。本文的要点来自对上述两本书的总结,也有一些自己的经验,下面是具体内容。基础规范关于函数的规范总体来讲,函数

2021-04-23 08:47:18 82

原创 LeetCode504. Base 7

Given an integer, return its base 7 string representation.Example 1:Input: 100Output: "202"Example 2:Input: -7Output: "-10"Note:The input will be in range of [-1e7, 1e7].class Solution {public: string convertToBase7(int num) ...

2020-06-20 16:19:43 133

原创 LeetCode503

Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number of a number x is the first greater number to its traversing-order next in the array, w

2020-06-19 16:16:06 160

原创 小问题纪录2020-06

什么是宽字符?用多个字节来代表的字符称之为宽字符。

2020-06-18 15:45:55 137

原创 LeetCode498. Diagonal Traverse

Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image.Example:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Output: [1,2,4,7,5,3,6,8,9]Explanation:Note:..

2020-06-18 14:36:44 113

原创 LeetCode502. IPO

Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the IPO. Since it has limited resources, it can only finish at mostkdist..

2020-06-14 12:57:59 157

原创 LeetCode506. Relative Ranks

Given scores ofNathletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bronze Medal".Example 1:Input: [5, 4, 3, 2, 1]Output: ["Gold Medal", "Silver Medal",..

2020-05-19 15:45:21 144

原创 Pytorch保存和加载Module填坑

在加载保存了的pytorch网络模型时报错:Traceback (most recent call last): File "<input>", line 1, in <module> File "/home/lihua/anaconda3/envs/Autoenc/lib/python3.5/site-packages/torch/serialization.py", line 367, in load return _load(f, map_location

2020-05-11 11:22:04 3691

原创 centos8安装mysql5.7出现问题

警告提示:[/usr/lib/tmpfiles.d/mdadm.conf:1] Line references path below legacy directory /var/run/, updating /var/run/mdadm → /run/mdadm; please update the tmpfiles.d/ drop-in file accordingly.[/usr/li...

2020-05-08 10:40:48 7134 6

原创 Small operations on Centos

git保存密码:git config --global credential.helper store

2020-05-07 16:21:39 173

原创 记录一下vim设置偏好

inoremap ( ()<ESC>i "设置(自动补全inoremap [ []<ESC>i "设置[自动补全inoremap { {}<ESC>i "设置{自动补全inoremap < <><ESC>i "设置<自动补全inoremap ' ''<ESC>i "设置'自动补全inoremap...

2020-05-06 19:05:27 190 1

原创 Small Questions

本博客用于记录学习过程中遇到的小问题:)explicit关键字简单说就是防止编译器的自动转换,参考:here。

2020-05-06 07:17:38 177

原创 RESTful API的Hellow,World!

什么,你连RESTful API都不知道!开个玩笑。因为疫情的原因呆在家里,准备回学校了。过程中公司的导师联系我做一个小项目,需要使用到RESTful API的接口。这种接口已经是后台架构设计的一种趋势了,还是有必要了解一下的。但是因为我在学校的专业和这个完全不相关,所以摸索了很久才最终搞了个Hellow,World!不过就算这样也还是很激动了,所以打算记录一下,因为我也是完全新手,所以尽量写...

2020-05-04 12:24:07 531 2

原创 LeetCode501. Find Mode in Binary Search Tree

Given a binary search tree (BST) with duplicates, find all themode(s)(the most frequently occurred element) in the given BST.Assume a BST is defined as follows:The left subtree of a node contain...

2020-04-25 22:04:59 111

原创 LeetCode500. Keyboard Row

Given a List of words, return the words that can be typed using letters ofalphabeton only one row's of American keyboard like the image below.Example:Input: ["Hello", "Alaska", "Dad", "...

2020-04-24 10:24:35 143

原创 LeetCode 497. Random Point in Non-overlapping Rectangles

Given a list ofnon-overlappingaxis-aligned rectanglesrects, write a functionpickwhich randomly and uniformily picks aninteger pointin the spacecovered by the rectangles.Note:Aninteger poi...

2020-04-23 20:24:06 177

原创 LeetCode496. Next Greater Element I

You are given two arrays(without duplicates)nums1andnums2wherenums1’s elements are subset ofnums2. Find all the next greater numbers fornums1's elements in the corresponding places ofnums2....

2020-04-22 07:54:24 111

原创 LeetCode495. Teemo Attacking

In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attackingascendingtime series towards Ashe and the poisoning tim...

2020-04-21 07:36:48 214

原创 LeetCode494. Target Sum

You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols+and-. For each integer, you should choose one from+and-as its new symbol.Find out how m...

2020-04-20 09:01:59 97

原创 LeetCode493 Reverse Pairs

Given an arraynums, we call(i, j)animportant reverse pairifi < jandnums[i] > 2*nums[j].You need to return the number of important reverse pairs in the given array.Example1:Input: ...

2020-04-19 08:26:48 125

原创 LeetCode492 Construct the Rectangle

For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L...

2020-04-17 10:13:46 106

原创 LeetCode491. Increasing Subsequences

Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2.Example:Inp...

2020-03-06 11:45:44 104

原创 488. Zuma Game

Think about Zuma Game. You have a row of balls on the table, colored red(R), yellow(Y), blue(B), green(G), and white(W). You also have several balls in your hand.Each time, you may choose a ball in ...

2020-03-05 12:21:42 2075

原创 LeetCode487 Max Consecutive Ones II

。。。

2020-03-05 09:19:49 125

原创 LeetCode486. Predict the Winner

Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player picks a...

2020-03-04 07:53:38 109

main.go

main.go

2023-01-19

空空如也

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

TA关注的人

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