自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Czyaun的博客

学海无涯

  • 博客(202)
  • 收藏
  • 关注

原创 剑指ofer题型归类

51. 构建乘积数组考察知识点:左阶乘、右阶乘52. 正则表达式匹配考察知识点:DFS、分类讨论(往前探测)53. 表示数值的字符串考察知识点:分类讨论54. 字符流中第一个不重复的字符考察知识点:map、队列55. 链表中环的入口节点考察知识点:快慢指针56. 删除链表中重复的结点考察知识点:指针57. 二叉树的下一个结点考察知识点:中序遍历、分类讨论58. 对称的二叉树考察知识点:DFS59. 按之字形顺序打印二叉树考察知识点:BF

2020-10-15 16:03:42 176

原创 归并排序

核心思想:采用分治法,将数组划分成两部分,每次对这两部分进行合并。例如:49, 38, 65, 97, 38, 76, 13, 27第一趟:49 38 ——> 38 496597——> 65973876——> 38761327——> 1327第二趟:38 49 6597 ——>38 49 65 973876 1327——>13 27 38 76第三趟:38 4...

2020-09-10 17:23:34 185

原创 RBtree节点结构

[1]https://www.bilibili.com/video/BV1zt411V7Ye?p=20

2020-09-09 18:58:50 222

原创 deque内存管理

[1]https://www.bilibili.com/video/BV1zt411V7Ye?p=18

2020-09-09 18:56:55 182

原创 C++基础——友元函数

友元提供了不同类的成员方法之间、类的成员方法与一般方法之间进行数据共享的机制。通过友元,一个不同方法或另一个类中的成员方法可以访问类中的私有成员和保护成员。友元的作用是提高了程序的运行效率(即减少了类型检查和安全性检查等都需要时间开销),但它破坏了类的封装性和隐藏性,使得非成员函数可以访问类的私有成员。友元方法:友元方法是可以直接访问类的私有成员的非成员方法。它是定义在类外的普通方法,它不属于任何类,但需要在类的定义中加以声明,声明时只需在友元的名称前加上关键字friend,其格式如下:..

2020-08-17 18:03:10 200

原创 骰子期望

扔n个骰子,第i个骰子有可能投掷出Xi种等概率的不同的结果,数字从1到Xi。所有骰子的结果的最大值将作为最终结果。求最终结果的期望。链接:https://www.nowcoder.com/questionTerminal/86ef0d5042934ef7819035794377a507?orderByHotValue=1&page=1&onlyReference=false输入描述:第一行一个整数n,表示有n个骰子。(1 <= n <= 50)第二行n个整数,表.

2020-08-17 17:00:50 1805

原创 Number of Subarrays with Bounded Maximum(区间子数组个数)

We are given an array A of positive integers, and two positive integers L and R (L <= R).Return the number of (contiguous, non-empty) subarrays such that the value of the maximum array element in that subarray is at least L and at most R.Example :I

2020-08-15 16:48:56 191

原创 Global and Local Inversions(全局倒置和局部倒置)

We have some permutation A of [0, 1, ..., N - 1], where N is the length of A.The number of (global) inversions is the number of i < j with 0 <= i < j < N and A[i] > A[j].The number of local inversions is the number of i with 0 <= i &l

2020-08-10 11:50:11 220

原创 Swap Adjacent in LR String(交换字符串LR位置)

In a string composed of 'L', 'R', and 'X' characters, like "RXXLRXRXL", a move consists of either replacing one occurrence of "XL" with "LX", or replacing one occurrence of "RX" with "XR". Given the starting string start and the ending string end, return T

2020-08-10 11:12:17 263

原创 Reach a Number(到达目的地)

You are standing at position 0 on an infinite number line. There is a goal at position target.On each move, you can either go left or right. During the n-th move (starting from 1), you take n steps.Return the minimum number of steps required to reach t

2020-08-06 16:49:41 410

原创 最短路径算法

1.单源点最短路径单源点路径算法的核心:根据松弛原理,在两个顶点之间查找第三个顶点,使其距离最短。用到的都是DP的思想1.1 迪杰特斯拉Dijkstra以出发点为中心,向四周进行扩散,每次将当层的节点作为(i,j)最短距离的第三个顶点k,若加入第三个顶点k后满足(i,j) > (i,k) + (k,j),则更新(i,j) = (i,k) + (k,j).核心:每次查找最短距离的点1.2 Bellman-Ford算法跟Dijkstra算法的思路一致,不过,该算法以查找最短边为核心

2020-08-05 15:01:29 300

原创 Daily Temperatures

739.Daily TemperaturesGiven a list of daily temperaturesT, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there i...

2020-04-29 09:51:47 166

原创 Monotone Increasing Digits

738.Monotone Increasing DigitsGiven a non-negative integerN, find the largest number that is less than or equal toNwith monotone increasing digits.(Recall that an integer hasmonotone increasi...

2020-04-22 20:58:40 161

原创 My Calendar II

731.My Calendar IIImplement aMyCalendarTwoclass to store your events. A new event can be added if adding the event will not cause atriplebooking.Your class will have one method,book(int star...

2020-04-20 08:32:23 151

原创 My Calendar I

729.My Calendar IImplement aMyCalendarclass to store your events. A new event can be added if adding the event will not cause a double booking.Your class will have the method,book(int start, i...

2020-04-19 23:26:28 197

原创 Accounts Merge

721.Accounts MergeGiven a listaccounts, each elementaccounts[i]is a list of strings, where the first elementaccounts[i][0]is aname, and the rest of the elements areemailsrepresenting emails...

2020-04-16 09:53:43 276

原创 Maximum Length of Repeated Subarray

718.Maximum Length of Repeated SubarrayGiven two integer arraysAandB, return the maximum length of an subarray that appears in both arrays.Example 1:Input:A: [1,2,3,2,1]B: [3,2,1,4,7]Out...

2020-04-16 09:11:20 161

原创 Subarray Product Less Than K

713.Subarray Product Less Than KYour are given an array of positive integersnums.Count and print the number of (contiguous) subarrays where the product of all the elements in the subarray is les...

2020-04-11 17:37:34 137

原创 Minimum ASCII Delete Sum for Two Strings

712.Minimum ASCII Delete Sum for Two StringsGiven two stringss1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.Example 1:Input: s1 = "sea", s2 = "eat"Output: ...

2020-04-11 15:32:08 121

原创 Number of Longest Increasing Subsequence

673.Number of Longest Increasing SubsequenceGiven an unsorted array of integers, find the number of longest increasing subsequence.Example 1:Input: [1,3,5,4,7]Output: 2Explanation: The two l...

2020-03-30 23:36:50 285

原创 Find K Closest Elements

Given a sorted array, two integerskandx, find thekclosest elements toxin the array. The result should also be sorted in ascending order. If there is a tie, the smaller elements are always prefer...

2020-03-14 20:54:20 139

原创 快速排序的递归实现和非递归实现

之所以写这篇博客,主要是因为对于快排来说,递归的实现已经在我们脑海当中根深蒂固,以至于我们的条件反射就是快排难道还有非递归实现?我怎么之前都没见过。也是为了加深自己对递归的进一步的理解~快速排序的原理我这里就不多讲啦,实现的话就是分治法。想具体了解的可以参考我的另外一篇博客插入类排序。也欢迎大家关注我的博客~~HH递归实现的代码:#include <iostream>#...

2020-03-14 20:29:28 266

原创 Print Binary Tree

Print a binary tree in an m*n 2D string array following these rules:The row numbermshould be equal to the height of the given binary tree. The column numbernshould always be an odd number. The...

2020-03-13 22:44:39 126

原创 Find Duplicate Subtrees

Find Duplicate SubtreesGiven a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of anyoneof them.Two trees are duplicate if ...

2020-03-11 23:26:53 154

原创 2 Keys Keyboard

1.解析题目大意,利用复制和粘贴,求解最少经过几步可以完成N个'A'2.分析我刚开始理解错题意啦,我以为只要是不少于n个'A'字符就可以。例如n= 7,如果不要求个数的话,经过6步就可以,第1步复制,第2步粘贴,第3步粘贴,此时为AAA,第4步复制,第5步粘贴,第6步粘贴,此时为AAAAAAAAA。原来只需要复制n个A,参考@Grandyang博主的思路,我还是习惯用DP,因...

2020-03-10 18:48:24 185

转载 深入浅出静态链接和动态链接

        这篇文章是我转载的博客,强烈建议大家去原作者的博客看,转载在这里只是方便我查看。首先大概介绍一下,编译分为3步,首先...

2020-03-08 12:26:07 271

转载 从编写源代码到程序在内存中运行的全过程解析

从编写源代码到程序在内存中运行的全过程解析 原创 ...

2020-03-08 12:11:11 761

原创 HighChart和Echart上填充容器问题

整体上,Echart和HighChart基本使用上是差不多的,官方都提供了很丰富的示例,在其基础上简单的修改就可以使用。要特别注意的一点是:HighChart填充图表的容器的高度和宽度无需指定,编译器可以自动帮你调整好位置;但Echart必须要显示的指定容器的高度和宽度,须要显示的指定容器的高度和宽度,须要显示的指定容器的高度和宽度,之前碰到这个问题,我调试了好久。即要显示设置sty...

2020-03-05 21:42:41 228

原创 Exclusive Time of Functions

1.解析题目大意,计算每一个函数执行的时间。2.分析题目看起来蛮简单的,但其实不然,最难理解的部分,就是在"end"状态这里,实际上,当检测到"end"状态的时候,不只是当前对应的id的函数会执行一个单位的时间,(这里主要是方便处理而已)上一个函数也会执行一个单位,然后上一个函数执行的起始时间要加1,其他部分就比较容易理解啦,利用一个栈保存当前最新执行的函数id,当检测到一...

2020-03-05 21:34:59 131

原创 Shopping Offers

1.解析题目大意,给定每个商品的价值和优惠券(优惠券可以重复使用),求解所购买商品最少花多少钱。2.分析我最初看到这道题的时候,求最值,以为是DP,但在设计的过程中,发现有个问题,就是所取到的值并不是局部的最优解,因为不单要考虑优惠券,而且还要考虑无法使用优惠券的那部分的钱,所以不是DP。参考@Grandyang博主的思路,发现其实采用深度优先检索是最简便的,利用一个临时变量...

2020-03-05 21:09:42 222

原创 累加和矩阵问题总结

这类题我做的不是很多,但碰到过的大致都具有以下特点:①要求数组内的元素下标是连续的,即连续子序列②不考虑排列顺序,只考虑连续子序列的总和主要用到一个定理:a + b = c,那么b = c - a;即可以通过累加和的方式进行求解,在往前遍历累加的过程中,可以直接求解出目标。如果只是判断是否存在等于目标值,只需用set容器保存之前的值即可;若要求满足要求的总的个数,需要用到map去存...

2020-03-02 08:48:45 1332

原创 vector容器的动态分配空间

vector容器的底层实现基于数组,里面封装了大量高效的方法,可以完美取代掉数组。整个容器的核心实际上就是动态分配内存,也是其性能优于数组的重要原因。下面重点解析它的核心函数push_back函数:当数组中增加一个元素x的时候,先判断是否还有备用空间;如果还有备用空间,则将当前指针的值设为x,并将当前的指针加1;若备用空间已经用完,如果之前的空间为0,则重新分配大小为1的空间,否则将空间扩容为...

2020-03-01 21:33:58 2638

原创 Task Scheduler

1.解析题目大意,求解最优的系统调度时间。要求,两个相同任务之间的时间间隔不能小于n2.分析这道题没什么套路,我个人感觉还是比较难的,尤其题目意思,解题思路也不是很容易想到。我最初看到求解最值,我以为是动态规划。参考@Grandyang博主的思路,讲解的很清晰。我们可以先看一个例子,例如:['A', 'B', 'A', 'B','A','B','C'] n = 2...

2020-02-28 20:36:04 127

原创 Valid Triangle Number

1.解析题目大意,判断数组存在几个有效的三角形。2.分析刚开始,我看到这题我觉得很大可能就是定位法,可能刷题刷多啦。但我觉得数据规模有点小,暴力穷举应该没什么问题,然后就直接用了递归,可以看到,用递归实现是比较容易的,这个遍历即可。但无法OJ,我也是无语。class Solution {public: int triangleNumber(vector<i...

2020-02-27 20:49:57 270

原创 Valid Square

1.解析题目大意,判断所给的点是否能构成正方形。2.分析题目还是蛮简单的。我采用了最简单的思路,给定四个没有任何顺序的点,所以,第一步先大致确定每个点的位置,根据每个点在X轴上的位置对这四个点进行排序,然后计算宽,然后根据Y轴上的位置,计算高;分别判断这四条边是否相等,若相等,再进一步判断两边之和是否等于对角线,若满足,则是正方形。这里,需要注意特殊情况:所有的点是重合的,即只...

2020-02-26 21:15:44 202

原创 pl/sql如何导出单张数据库表

本来很简单的一个问题,找了很多博客,终于解决这个问题。右击要导出的表,然后选择"导出数据",选择"SQL插入"选项就可以直接导出了。[1]https://blog.csdn.net/dulixing0154084/article/details/100776612...

2020-02-26 11:58:00 207

原创 字符串处理函数

字符串的处理在日常的编程当中相当重要,主要是对所给的字符串进行合理的切割。1.输入函数getline1.1 cin.getline函数原型:istream& getline( char * str, streamsize n, char delim ) //str----输入的字符串 n-----所截取的字符串长度 delim-------结束标识符具体实例...

2020-02-25 23:19:07 260

原创 accumulate累加和函数

STL库提供了很方便的计算数组所有元素的和的函数,具体的实现也比较简单,如下://stl_numeric.htemplate <class InputIterator, class T>T accumulate(InputIterator first, InputIterator last, T init) { for ( ; first != last; ++first...

2020-02-24 22:28:31 324

原创 动态规划总结

算法题型当中应该说最难的就是动态规划啊,贪心算法很大程度上取决于贪心策略,所以动态规划整体上比贪心应用更广泛,且贪心未必能找到最优解,但动态规划一定可以找到最优解。一般运用动态规划的地方有以下特征:①求最值②不要求序列连续从硬币和相等子序列问题中,发现一个trick:如果要求数组中的个数不限:从小到大遍历(可以保证一个数可以取多次);若个数有限定:从大到小遍历(数只能取一次);...

2020-02-24 22:19:37 169

原创 count和count_if函数

今天在优化代码的时候碰巧看到count_if函数,研究了一下,该函数主要用于统计序列化容器(内部没有实现特定排序算法的容器,例如vector,list,queue,stack等)满足条件的值,还是比较有用的。具体的实现源码如下://stl_algo.htemplate <class InputIterator, class Predicate>typename iterato...

2020-02-23 23:04:57 694

空空如也

空空如也

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

TA关注的人

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