自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(118)
  • 资源 (10)
  • 收藏
  • 关注

原创 LeetCode 27. Remove Element

Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input arra...

2018-11-22 12:35:19 215

原创 LeetCode 26. Remove Duplicates from Sorted Array

Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifyi...

2018-11-21 13:39:09 190

原创 Leetcode 61. Rotate List

Given a linked list, rotate the list to the right by k places, where k is non-negative.Example 1:Input: 1->2->3->4->5->NULL, k = 2Output: 4->5->1->2->3->NULLExplan...

2018-11-20 13:35:20 218

原创 LeetCode 15. 3Sum

Given an array nums of n integers, are there elements a, b, c in nums such that a + b+ c = 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not conta...

2018-11-19 13:26:42 226

原创 LeetCode 1. Two Sum

Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same ...

2018-11-19 00:12:54 112

原创 LeetCode 16. 3Sum Closest

Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would ...

2018-11-18 17:45:50 107

原创 二叉树的深度

题目描述输入一棵二叉树,求该树的深度。从根结点到叶结点依次经过的结点(含根、叶结点)形成树的一条路径,最长路径的长度为树的深度。题解:树的的深度为左右子树深度的最大值加1。/*struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val...

2018-11-16 14:55:58 156 1

原创 二叉搜索树的第k个节点

题目描述给定一棵二叉搜索树,请找出其中的第k小的结点。例如, (5,3,7,2,4,6,8)    中,按结点数值大小顺序第三小结点的值为4。题解:此题就是求中序遍历的第k个节点。/*struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(i...

2018-11-16 14:35:27 125

原创 LeetCode 88. Merge Sorted Array

思路:将nums2与nums1中的元素从后往前比较,放到nums1的最后,如果nums1的元素没了,就将nums2剩下的元素放到nums1中 ,同理将nums1中剩下的元素放到nums1中。class Solution {public: void merge(vector<int>& nums1, int m, vector<int>& ...

2018-11-16 11:47:30 133

转载 什么是反向索引

反向索引英文名叫做Inverted index, 顾名思义, 是通常意义下索引的倒置。举个例子:我们用不同的数字索引不同的句子(比如以下三句在文本中是按照0,1,2的顺序排列的)0 : “I love you”1 :“I love you too”2: “I dislike you”如果要用单词作为索引,而句子的位置作为被索引的元素,那么索引就发生了倒置:“I” :{0, ...

2018-11-04 15:38:12 6628 3

原创 为文档中包含的单词生成一个列表

建立自己的散列表, 散列表中的节点包含指向单词的指针、单词出现的频率以及指向表中的下一个节点#define _CRT_SECURE_NO_WARNINGS#include <iostream>#include <string>using namespace std;//圣经中只有29131个单词, 采用传统的方法, 将大于29131的最小的质数作为散列表...

2018-11-04 14:44:46 699

原创 约瑟夫问题

题目描述n个人(n<=100)围成一圈,从第一个人开始报数,数到m的人出列,再由下一个人重新从1开始报数,数到m的人再出圈,……依次类推,直到所有的人都出圈,请输出依次出圈人的编号.输入输出格式输入格式: n m 输出格式: 出圈的编号 输入输出样例#include <queue>#include <iostream&...

2018-10-13 23:26:05 158

原创 多重背包

#include <iostream>#include <vector>#include <algorithm>using namespace std;int n, vol;void ZeorOnePack(int nvalue, int nweight, vector<int>& F) { for (int j = vo...

2018-10-13 10:59:26 97

原创 完全背包

//完全背包: 有N种物品和一个容量为V的背包,每种物品都有无限件可用。 放入第i种物品的消耗空间是ci,得到的价值是wi//求解:将那些物品装入背包, 可使得这些物品的耗费的空间不超过背包容量, 且价值总和最大#include <iostream>#include <vector>#include <algorithm>using names...

2018-10-13 10:58:48 110

原创 01背包

//0 - 1 背包问题:给定 n 种物品和一个容量为 C 的背包,物品 i 的重量是 wi,其价值为 vi 。////问:应该如何选择装入背包的物品,使得装入背包中的物品的总价值最大?#include <iostream>#include <vector>using namespace std;/** val[n][vol]为最优解, 如果val[...

2018-10-13 10:57:01 91

原创 KMP算法实现

#include <iostream>#include <stdlib.h>#include <string.h>using namespace std;void prefix_table(int prefix[], char pattern[], int n){ int len = 0; int j = 1; prefix[0] = 0;...

2018-10-13 10:54:04 565

原创 文本文件的读写

#include <iostream>#include <fstream>using namespace std;int main() { ofstream out("1.txt"); if (out.is_open()) { out << "this is a line" << endl; out <<

2018-10-13 10:10:32 173

原创 find实现

// find.cpp: 定义控制台应用程序的入口点。//#include <vector>#include <iostream>#include <map>#include <string>template<class InputIterator, class T>InputIterator find(InputIte...

2018-10-13 10:10:24 417

原创 static_cast

#include <iostream>#include <string>using namespace std;class ANIMAL{public: ANIMAL() :_type("ANIMAL"){}; virtual void OutPutname(){ cout << "ANIMAL"; };private: string _t...

2018-10-13 10:10:19 417

原创 C++模板中的省略号和可变参数模板

#include <iostream>using namespace std;void print() { cout << "hello world" << endl;}template<class T>void print(T a) { cout << a << endl;}template&

2018-10-13 10:10:13 1338

原创 topk面试题

#include <iostream>#include <queue>#include <vector>#include <functional>using namespace std;vector<int> GetLeastNumber(vector<int> input, int k){ vector&...

2018-10-13 10:09:31 243

原创 左值引用和右值引用

#include <iostream>using namespace std;int main() { int i = 42; //i是左值对象, 42是常量,是右值 int &j = i; // 左值引用 //int &z = 42; 错误, 因为左值对象只能绑定到左值, 右值对象只能绑定到右值对象, 因为右值对象是临时的 //因此, 右值引用只能...

2018-10-12 21:05:03 120

原创 windows第一个多线程

#include <iostream>#include <Windows.h>using namespace std;DWORD WINAPI func(LPVOID p){ cout << *(int *)p << endl; cout << "线程normal id " << GetCurren

2018-10-12 21:03:25 110

原创 智能指针的使用

share_ptr#include <iostream>#include <memory>#include <thread>#include <chrono>#include <mutex>struct Base { Base() { std::cout << "Base::Base()" &amp

2018-10-12 21:01:48 198

原创 信号量

#include <iostream>#include <windows.h>using namespace std;CRITICAL_SECTION cs;HANDLE handle[10];int threadNum = 10;static int num = 0;unsigned long WINAPI func(LPVOID p);HAN...

2018-10-12 20:56:57 114

原创 10进制转换成二进制

#include <iostream>using namespace std;void DtoB(int d){ if (d / 2) DtoB(d / 2); cout << d % 2;}int main(){ int n; cin >> n; DtoB(n);} 

2018-10-12 20:51:23 686 1

原创 几种常见设计模式的实现

单例设计模式的实现:(懒汉式,线程安全)#include <iostream>#include <mutex>using namespace std;class Singleton{public: static Singleton* getInstance(); void SingletonOperation();private: static S...

2018-10-12 20:24:33 285

原创 指针和引用的区别

相同点:都是地址的概念:指针指向一块内存,它的内容是所指向的内存的地址;引用是某块内存的别名区别:1. 指针是一个实体, 而引用仅是个别名2. 引用使用的时候不需要解引用(*), 指针需要解引用3. 引用只能在定义时被初始化一次,之后不可变;指针可变;4. 引用不能为空,指针可以为空6, sizeof引用得到的是所指向的变量的大小,sizeof指针得到的是指针本身7...

2018-10-12 11:25:00 111

原创 传值、传指针和传引用的区别

传值:void mySwap(int a, int b){ int temp = a; a = b; b = temp;}传指针(1):void mySwap(int *a, int *b){ int *temp = a; a = b; b = temp;}(2)void mySwap(int *a, int *b){ int temp = *a;...

2018-10-12 11:10:29 821 1

原创 判断正方形和圆形相交

只要两个中心在水平和垂直方向上的投影之间的距离,都小于等于Edge / 2 + R 即可。

2018-10-12 10:25:36 2737 1

原创 内存泄漏与智能指针

对于c++这种没有垃圾回收机制的语言来说,主要关注两种类型的内存泄漏;(1) 堆内存泄漏:比如使用new、malloc等从堆中分配的资源,没有用delete和free删掉(2) 系统资源泄漏:系统分配的资源如socket等没有被释放掉。    智能指针是一个类, 这个类的构造函数会传入一个普通指针,析构函数中释放传入的指针。智能指针都是栈上的对象,所以当函数(或程序)结束时会自动会被释...

2018-10-12 09:41:57 1096 1

原创 C++内存管理

1. 内存分配方式在c++中内存分为5个区, 分别是堆、栈、自由存储区、全局/静态存储区和常量存储区。堆: 堆是需要程序员手动分配和释放,属于动态分配方式。内存空间没有限制, 内存空间不连续,因此会产生内存碎片。操作系统有一个记录内存空间的链表,当收到内存申请遍历链表,找到第一个空间大于申请空间的堆结点,然后将节点分配给程序,并将该节点从链表中删除,如果空间比要分配的空间大,就将剩余空间重...

2018-10-11 21:35:07 190

原创 进程与线程的区别

进程是一个具有独立功能的程序关于某个数据集合的一次运行活动,进程是一个实体,每一个进程都有自己的地址空间;进程是一个执行中的程序, 是资源分配的基本单位。程序是指令和数据的有序集合。线程是进程的一个执行流,是CPU进行调度和分派的基本单位。通常在一个进程中可以包括若干个线程,当然一个进程至少有一个线程。每个线程都有自己的堆栈和局部变量。 进程和线程的区别:进程是资源分配的最小单...

2018-10-11 16:54:04 89

原创 统计一个已经排序的数组中元素不重复出现的个数

#include <iostream>using namespace std;int RemoveDuplicateElement(int arr[], int length){ int count = 0; if (length == 0) return count; ++count; for (int i = 1; i < length; ++i) ...

2018-10-11 16:33:51 661

原创 哈夫曼编码

哈夫曼编码的第一步是构造哈夫曼树, 第二步是为哈夫曼树的每一条边编码。构造哈夫曼树的时候,每次取权值最小的两个边合并,边小的放左边,边大的放右边。哈夫曼树的结点总个数是哈夫曼叶节点个数的2倍减1代码实现:#include <iostream>#include <string>using namespace std;struct Node{ i...

2018-10-11 12:18:47 2158

原创 求最小公倍数

求a和b的最小公倍数。a和b的最小公倍数 = a / gcd(a, b) * b; 其中gcd(a, b)是a和b的最大公约数,可以通过欧几里得算法求得。#include <iostream>#include <algorithm>using namespace std;int gcd(int a, int b){ if (a < b) swa...

2018-10-11 00:35:13 85

原创 欧几里得算法

#include <iostream>#include <algorithm>using namespace std;int gcd(int a, int b){ if (a < b) swap(a, b); while (a % b) { int r = a % b; a = b; b = r; } return b;}...

2018-10-11 00:28:46 432

原创 并查集

并查集,在一些有N个元素的集合应用问题中,我们通常是在开始时让每个元素构成一个单元素的集合(换句换说每个节点都是一棵树),然后按照一定的顺序将属于同一组的元素合并,其间要反复查找一个元素在哪个元素集合中。题目描述如题,现在有一个并查集,你需要完成合并和查询操作。输入输出格式输入格式: 第一行包含两个整数N、M,表示共有N个元素和M个操作。接下来M行,每行包含三个整数Zi...

2018-10-10 23:12:46 152

原创 有关大数的运算

大数加法:    用字符数组存储数, 然后用两个新数组存储相加的两个字符数组的逆序,然后读数的时候反向读。#include <iostream>#include <string>using namespace std;//大数的最大位数const int MAX = 1000;//返回和的最大位数int Addition(char num1[]...

2018-10-10 12:23:39 164

原创 把字符串转换成整数

将字符串转换成为整数,要注意边界问题,比如说要转换的整数超过了最大的整数,还有处理空字符串的情况。#include <iostream>#include <string>using namespace std;//枚举型的值判断值是否有效enum {kValid = 0, kInvalid};int status = kValid;long lon...

2018-10-10 12:09:55 240

flink-java-1.14.CHM

flink 1.14 chm 文档 java

2021-12-04

flink-1.13.CHM

flink-1.13.2 CHM 文档

2021-12-04

算法导论第三版答案英文版

算法导论第三版答案英文版

2017-06-24

泛函分析导论及应用.[加]Erwin Kreyszig

泛函分析导论及应用.[加]Erwin Kreyszig

2017-06-22

CSS参考手册

CSS参考手册v4.2.4

2017-06-21

Java编程技术(谭浩强编)

Java编程技术 谭浩强编

2017-06-18

矩阵论答案-程云鹏版

矩阵论答案-程云鹏版

2017-06-18

understanding machine learning theory algorithms

Shalev-Shwartz , S Ben-David

2017-06-16

The Nature of Statistical Learning Theory

统计学习理论本质的英文版

2017-06-16

空空如也

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

TA关注的人

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