自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 二叉树的深度

递归(深度遍历dfs)时间复杂度:O(n),遍历二叉树每个结点空间复杂度:O(n),递归栈深度就是二叉树的高度,其中最坏情况是二叉树退化为链表,深度最大为n/*struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { }};*/class Solution {public: in

2022-02-27 19:20:27 484

原创 MYSQL中 on和where的区别

https://blog.csdn.net/tayngh/article/details/99684035在这个博客的基础上补充一下。这是用on的输出结果:这是用where的输出结果:结合上面链接的博客的文字内容理解,就明朗了。

2022-02-25 21:58:41 675

原创 数据分析之数理基础与概率统计

文章目录随机误差的分布是`正态分布(高斯分布)`中心极限定理和大数定律两类错误置信区间、置信度(置信水平)协方差是啥,怎么判断协方差正负辛普森悖论的例子随机误差的分布是正态分布(高斯分布)根据中心极限定理,大量独立的随机变量之和趋向于某个稳定的分布,被称为正态分布(高斯分布)。那么大量的随机(随机就说明是独立的)误差之和就趋向于正态分布。中心极限定理和大数定律中心极限定理是说无论抽样分布(卡方、t、F)如何,均值服从正态分布。(正态分布是抽样分布的基础。三大抽样分布是从正态分布抽出的样本的分布。指的

2022-02-23 22:27:53 1065

原创 Jupyter Notebook markdown 添加目录

我想要的是这个效果:而不光只是这个效果:而这个侧边栏目录怎么弄,网上已经说烂了。其实很简单,只需进入:勾上:ok之后,notebook最上方就出现目录啦。并且也可直接通过:[toc]或[TOC]生成。如果不勾上“add notebook toc cell”,是怎么样都不会在顶端产生目录的!...

2022-02-20 12:04:29 1136

原创 leecode-70. 爬楼梯

class Solution {public: int climbStairs(int n) { if(n<=2) return n; vector<int> dp(n+1, 1); //定义了n+1个整型元素的向量,且给出每个元素的初值为1 for(int i=2; i<=n; i++){ dp[i] = dp[i-1] + dp[i-2]; } return dp[n

2022-02-18 20:40:01 392

原创 C++反转链表

https://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca正规解法(反转链表,通过调整链表指针达到反转链表)时间复杂度:O(n), 遍历一次链表空间复杂度:O(1)/*struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { }};*/class Solution {public:

2022-02-18 16:14:52 3749

原创 sql常用操作之文本转换函数

题1https://www.nowcoder.com/practice/a5475ed3b5ab4de58e2ea426b4b2db76?tpId=240&tags=&title=&difficulty=0&judgeStatus=0&rp=0select exam_id, substring_index(tag, ',', 1) as tag, substring_index(substring_index(tag, ',', 2),

2022-02-16 17:13:43 1718

原创 python对array数组(或矩阵)进行重新排序(且索引确保不同)

首先需要知道一性质:pandas的dataframe或numpy的array、matrix,都可以直接通过索引列表(重)排序。例如三维的array数组:A,A.shape=(x,y,z)。则A[index列表]重排的就是x的元素顺序。同理B.shape=(n,x,y,z),则B[index列表]重排的就是n的元素顺序。下面是一维的测试:注意:使用random.sample是为了确保生成的索引号不同。np.random好像没有这个功能。......

2022-02-15 17:27:02 2950 1

原创 从尾到头打印链表

文章目录1.调用库函数reverse实现vector内部元素的翻转.2.递归法3.堆栈法4.反转链表(改变链表结构)5.利用vector的insert特性原题:https://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035?tpId=13&tqId=23278&ru=/practice/75e878df47f24fdc9dc3e400ec6058ca&qru=/ta/coding-interviews/ques

2022-02-14 14:23:29 588

原创 sql常用操作之限量查询

题1https://www.nowcoder.com/practice/fbe36305c6dd4954a05cc2f2f12e4f4a?tpId=240&tags=&title=&difficulty=0&judgeStatus=0&rp=0select uid, nick_name, register_timefrom user_infoorder by register_time asclimit 3select uid, nick_name, r

2022-02-13 19:38:56 1462

原创 sql常用操作之高级条件语句

题1https://www.nowcoder.com/practice/2ed07ff8f67a474d90523b88402e401b?tpId=240&tags=&title=&difficulty=0&judgeStatus=0&rp=0select uid, nick_name, achievement FROM user_info left join exam_record using(uid) lef

2022-02-12 23:38:26 556

原创 sql其他常用操作之空值处理

文章目录题目1题2题目1https://www.nowcoder.com/practice/69fc2b1df4144c0991e4b8280d8aba27?tpId=240&tags=&title=&difficulty=0&judgeStatus=0&rp=0先以子表写法:select exam_id, sum(incomplete) as incomplete_cnt, round(sum(incomplete) / count

2022-02-10 11:39:25 756

原创 sql窗口函数之聚合窗口函数(count,max,min,sum)

题1https://www.nowcoder.com/practice/2b7acdc7d1b9435bac377c1dcb3085d6?tpId=240&tags=&title=&difficulty=0&judgeStatus=0&rp=0SELECT uid, exam_id, ROUND(avg(if(score_cnt>1,(score-min_score)/(max_score-min_score)*100,score)),0) avg_

2022-02-09 19:20:51 2552

原创 C++统计字符串中各类型字符的个数

#include <iostream>#include <cstring>using namespace std;int main() { int letter = 0; int digit = 0; int space = 0; int other = 0; char buf[1024] = {0}; cin.getline(buf, sizeof(buf)); // write your code he

2022-02-08 17:47:15 7409

转载 C++迭代器遍历容器

详见:https://www.nowcoder.com/practice/0f7ab22e60ee4574a9d9c81412b26595?tpId=225&tqId=2193295&ru=/practice/f5e0b2ea13ee40308fcc275c0d06053f&qru=/ta/primary-grammar-cpp/question-ranking具体做法:对于迭代器,我们可以看成C++中的指针,它指向容器的某个位置,使用*可以访问该位置的值。我们输入数据以后,

2022-02-07 21:07:35 5067

原创 sql窗口函数之专用窗口函数(rank, dense_rank, row_number、lead、lag、first_value、last_value)

文章目录题1题2题3题4题5题1https://www.nowcoder.com/practice/255aa1863fe14aa88694c09ebbc1dbca?tpId=240&tags=&title=&difficulty=0&judgeStatus=0&rp=0SELECT tag, uid, rankingFROM ( SELECT tag, uid, ROW_NUMBER()

2022-02-07 15:37:56 822

原创 C++构造函数

#include <iostream>#include <string>using namespace std;// Person类class Person { public: string name; // 姓名 int age; // 年龄 // write your code here...... Person(string name, int age){

2022-02-06 14:46:28 284

原创 C++点和圆的关系

#include <iostream>using namespace std;// 点类class Pointer {private: int x; // x 坐标 int y; // y 坐标public: void setX(int x) { this->x = x; } int getX() { return x; } void setY(int y) {

2022-02-06 14:42:18 787

原创 C++设计立方体类

#include <iostream>using namespace std;class Cube { //定义属性private: int length, width, height; //成员变量//定义方法public: void setLength(int l){ //设置长 length = l; } void setWidth(int w){ //设置宽 width = w; }

2022-02-06 13:55:42 909

原创 C++编写函数实现两数交换(引用方式)

需要注意新建的函数名不能为swap,因为C++自带的两个整数转换的函数就为swap,因此需要换一个名字。观察上图,若swap()函数代码如下????,则意味着swap函数开辟了新内存地址,利用新的变量来存储这两个值。因此,只是在swap函数中交换m与n的值,在函数外面的main()主函数的m和n还是老样子。也就是说此m、n非彼m、n,因为内存地址不同。void swap(int m, int n){ int temp = m; m = n; n = temp;}但是如

2022-02-05 22:09:59 4191

转载 C++不死神兔问题

详见:https://www.nowcoder.com/practice/9fecec9c776c436b8a03ba0684ac76a7?tpId=225&tags=&title=&difficulty=0&judgeStatus=0&rp=0实际上是斐波那契数列问题:f(n)=f(n−1)+f(n−2)f(n) = f(n-1) + f(n-2)f(n)=f(n−1)+f(n−2)递归法时间复杂度:O(2n)O(2^n)O(2n),如图所示,树型递归,

2022-02-05 17:06:49 221

原创 sql多表查询之连接查询

题1https://www.nowcoder.com/practice/5c03f761b36046649ee71f05e1ceecbf?tpId=240&tags=&title=&difficulty=0&judgeStatus=0&rp=0select uid, exam_cnt, if(question_cnt is null, 0, question_cnt)from (select uid,

2022-02-05 16:14:06 319

原创 sql多表查询之合并查询(union)

题1https://www.nowcoder.com/practice/203d0aed8928429a8978185d9a03babc?tpId=240&tags=&title=&difficulty=0&judgeStatus=0&rp=0解1(select exam_id as tid, count(distinct uid) as uv, count(exam_id) as pvFROM exam_recordgro

2022-02-05 15:50:14 5966

原创 sql多表查询之嵌套子查询

文章目录题1题2法1法2:两次left join表连接:题3法1法2:使用in运算符分步查询题1https://www.nowcoder.com/practice/b1d13efcfa0c4ecea517afbdb9090845?tpId=240&tags=&title=&difficulty=0&judgeStatus=0&rp=0select tag, count(tag) as tag_cntfrom exam_record

2022-02-04 23:05:40 2327

原创 C++函数实现计算一个数的阶乘

递归#include <iostream>using namespace std;long long factorial(int n);int main() { int n; cin >> n; cout << factorial(n) << endl; return 0;}long long factorial(int n) { // write your code here......

2022-02-04 13:18:29 4921

转载 C++使用字符函数统计字符串中各类型字符的个数

详见:https://www.nowcoder.com/practice/31bdbc70188f48e995fa3cbef36613c8?tpId=225&tags=&title=&difficulty=0&judgeStatus=0&rp=0本题不是用字符数组读入的字符串,而是直接用了string类。我们可以用length函数直接判断字符串的长度,然后遍历字符串,对于遍历到的字符依次用函数检查每个字符属于哪一类,相应类的变量加1.使用前三个函数检查字符即可

2022-02-04 12:11:11 2910

原创 C++统计字符串中子串出现的次数

详见:https://www.nowcoder.com/practice/9eb684f845a446f3b121472de2ea75cd?tpId=225&tags=&title=&difficulty=0&judgeStatus=0&rp=0利用find函数首先将字符数组转化为字符串str1和str2。从str1下标i开始查找str2,如果找得到,计数加1,并且i从找到的位置,后移一位。#include <iostream>#inclu

2022-02-04 11:57:07 6711 1

原创 C++编写函数实现两数交换(指针方式)

文章目录常规方式用swap不用swap引用变量方式(常规方式的函数形式)指针变量方式的非函数形式指针变量方式的函数形式常规方式用swap#include <iostream>#include <bits/stdc++.h>using namespace std;// write your code here......int main() { int m, n; cin >> m; cin >> n; /

2022-02-03 16:40:30 1462

原创 C++比较字符串大小(自己实现strcmp()函数)

详见:https://www.nowcoder.com/practice/963e455fdf7c4a4a997160abedc1951b?tpId=225&tags=&title=&difficulty=0&judgeStatus=0&rp=01.移动指针法但这种方法只适用于二个字符数组中从头开始,有几个相同字符的字符数组,不适用于其它情况。时间复杂度:O(n),n为较短的字符串的长度空间复杂度:O(1),只有指针,无额外空间输入mystrcmp函数的是

2022-02-03 16:08:52 7317

原创 sql聚合分组查询-分组查询。涉及到coalesce函数、with rollup的使用

知识coalescehttps://blog.csdn.net/yilulvxing/article/details/86595725COALESCE是一个函数,coalesce (expression_1, expression_2, …,expression_n)依次参考各参数表达式,遇到非null值即停止并返回该值。SQL实例select coalesce(success_cnt, 1) from tableA当success_cnt 为null值的时候,将返回1,否则将返回succes

2022-02-03 13:06:26 842

原创 C++数组元素处理--将数组 为 0 的元素都移至数组末尾,将非 0 的元素移至开始(保持原来的顺序不变)。

把数组中为0的元素都移至数组末尾,将非 0 的元素移至开始(保持原来的顺序不变)。

2022-02-02 17:31:49 1201

原创 C++创建动态数组

文章目录用指针-第一种用指针-第二种以下不是通过创建动态数组的方法用vector不用指针-第一种错误写法:正确写法:不用指针-第二种详见:https://www.nowcoder.com/practice/218b577112a24c23a41bdc01f28c18ac?tpId=225&tags=&title=&difficulty=0&judgeStatus=0&rp=0用指针-第一种C++申请动态数组是依靠指针,数组是int型的我们就新开一个int型的指针

2022-02-02 11:41:40 1075

原创 C++复制部分字符串

指针详见:https://www.nowcoder.com/practice/8f5b923683b94e549880e3c8370e3e55?tpId=225&tags=&title=&difficulty=0&judgeStatus=0&rp=0#include <iostream>using namespace std;int main() { char str[30] = { 0 }; // 开辟一块最大长度为30的字符串空间

2022-02-01 23:02:49 1862

原创 C++获取字符串长度

for#include <iostream>using namespace std;int main() { char str[100] = { 0 }; cin.getline(str, sizeof(str)); // write your code here...... char* ptr = str; int len = sizeof(str) / sizeof(char); int length = 0; for (i

2022-02-01 10:24:53 1014

原创 C++ 利用指针遍历数组

while#include <iostream>using namespace std;int main() { int arr[6] = { 0 }; int* ptr = arr; int len = sizeof(arr) / sizeof(int); for (int i = 0; i < len; i++) { cin >> arr[i]; } // write your code her

2022-02-01 10:07:08 2028

原创 C++结构体简单使用

#include <iostream>#include <string>using namespace std;struct student { // write your code here...... string name; int age; double height; };int main() { student s; cin >> s.name >> s.age >&g

2022-01-31 18:35:12 80

原创 C++字符串拼接

直接字符串相加即拼接主要注意的是输入字符串的方式,采用getline(cin,str)#include <iostream>#include <string>using namespace std;int main() { string s1, s2; getline(cin, s1); getline(cin, s2); // write your code here...... s1 += s2;

2022-01-31 18:23:27 9782 1

原创 C++构建二维数组

#include <iostream>using namespace std;int main() { int arr[4][3] = { // write your code here..... {22, 66, 44}, {77, 33, 88}, {25, 45, 65}, {11, 66, 99} }; int sum = 0; f

2022-01-31 18:11:18 123

原创 C++数组元素反转

详见及参考:https://www.nowcoder.com/practice/8c9793ae96974a9ebb153d90ef31d357?tpId=225&tags=&title=&difficulty=0&judgeStatus=0&rp=0双指针时间复杂度:循环最多执行n/2次,所以时间复杂度为O(n)。空间复杂度:需要额外常数级别的空间,所以空间复杂度为O(1)。#include <iostream>using namespace

2022-01-31 13:13:26 1189

原创 C++获取数组最值

时间复杂度:O(n),n为数组长度,遍历一次数组空间复杂度:O(1),无额外空间利用三目运算符#include <iostream>using namespace std;int main() { int arr[6] = { 0 }; int len = sizeof(arr) / sizeof(int); // sizeof(int)为4,sizeof(arr)为24 for (int i = 0; i < len; i++) {

2022-01-31 11:24:38 369

CCleaner_Pro_v5.61.7392.exe

CCleaner 小巧精悍、快速高效、安全稳定,可以对文件夹、历史记录、上网记录、回收站等进行垃圾清理, 并可对注册表进行垃圾项扫描、清理,附带启动项管理和软件卸载等功能。让您的 Windows 运行更快、效率更高、

2019-09-14

空空如也

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

TA关注的人

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