自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

晨识草的博客

竹密不妨流水过,山高不碍白云飞

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

原创 使用git进行团队协作编程

一. 创建一个organization前提:已经有github帐号,没有的话直接百度搜索github官网进行注册接下来按照截图进行操作:点击右上角自己的头像,然后选择settings接着在左边一栏选择organizations选择new organization按照要求填写相关信息,比如组织的名称和邮箱即可创建完组织后,可以邀请其他成员加入,直接发送地址栏中的地址给要邀请的成员即可,被邀请的成员直...

2018-03-28 20:08:00 1781

原创 无线路由器的设置简记

1.首先,打开浏览器,在地址栏中输入192.168.1.1,如果是以前没有设置过管理员密码的,会先是设置管理员密码的对话框,设置完后进入下一步(注:网上一些说法是有初始设置的管理员账号和密码是admin,但可能不一定是)2.如果是已经设置过管理员密码的话,则直接用密码登录3.点击最右边的路由设置4.在左侧的设置栏中可以进行各项内容的设置。 5.上

2017-02-12 17:19:34 334

原创 小知识点

1.virtualDestructorOfBaseClass#include<iostream>using namespace std;class Basea {public: Basea() { cout << "it is Basea" << endl; } virtual ~Basea() { cout << "destruction of Basea" <<

2016-06-16 16:19:30 311

原创 greedysnake 贪吃蛇

大一上学期软导的贪吃蛇代码,当时实现了很久,努力自己实现了大部分, 另外参考了师兄给的代码,最终才完整实现,但是没有实现自动的部分#include<stdio.h>#include<stdlib.h>#include<string.h>#include<time.h>#define SNAKE_MAX_LENGTH 20#define SNAKE_HEAD 'H'#define SNA

2016-05-08 13:28:11 1229

原创 double linked list双向链表

[tags] C++双向链表的实现与单向链表相近节点结构体类声明总结双向链表的实现(与单向链表相近)1. 节点结构体struct DouListNode { int elem; DouListNode *prev, *next; DouListNode(int e = 0, DouListNode *p = 0, DouListNode *n = 0) { elem = e

2016-04-27 21:28:24 3969

原创 栈和队列

栈和队列目录栈和队列栈FILO队列循环队列FIFO栈(FILO)栈是后进先出的数据结构。 内存中的栈区处于相对较高的地址,以地址的增长方向为上的话,栈地址是向下增长的,栈中分配局部变量空间,堆区则是向上增长的用于分配程序员申请的内存空间。(1)实现栈的几种简单操作:入栈,出栈,判断栈是否空,是否满(2)入栈和出栈比较重要#include<iostream>#include<algorith

2016-04-14 17:52:35 935

原创 leetcode 49: anagrams

leetcode-anagrams// leetcode 49: 将由相同字母组成的字符串进行分类// 解题思路:将字符串进行排序,排序完一样的字符串归为一类// 使用map来对字符串进行归类,最后转换为vector二维数组// 本题不要求最后输出的顺序#include &lt;iostream&gt;#include &lt;vector&gt;#include &lt;stri...

2019-02-18 15:47:24 267

原创 高精度乘法c++实现

高精度乘法c++实现注:高精度乘法是应聘中常见的笔试题,主要考察用字符串模拟乘法的过程,下面提供一个比较简单的版本实现。如果错误,请多指教。如:123 * 23(1)存储的时候从个位往前进行存储。(2)123的个位(第0位)乘以23得到49(result[0] = 9, result[1] = 4)(3)123的十位(第1位)乘以23得到460,(result[0 + 1] = (4 ...

2019-02-17 21:04:31 6239 2

原创 kmp字符串匹配

字符串匹配kmp算法非常高效,朴素匹配算法的复杂度是O(n*m),kmp的复杂度可以达到O(n + m)(n为模板的字符串长度,m为待匹配子串的长度)但是kmp算法理解起来还是需要一定的时间。一. 求next数组对于待匹配的字符串,求它的next并存储在数组中,也即各个长度前缀中前后相同的字符个数。例子:abccab这个字符串的前缀有:a, ab, abc, abcc, abcca, abccab...

2018-03-25 21:39:18 317

原创 ubuntu开机黑屏问题

系统只有ubuntu16,今天开机的时候突然就出现了黑屏开机后输入密码,就一直有一个错误报告的框闪动,内容是“system program problem detected”点击cancel后是一直黑屏,无法进入系统。ctrl+alt+f1进入命令终端后,sudo apt-get purge nvidia*sudo sushutdown(等一分钟左右)然后重新开机后可以进入系统...

2018-03-09 13:06:19 2954

原创 Qt入门----hello

一. Qt的安装参考网址:http://blog.csdn.net/xungjhj/article/details/71600437二. Qt实现最简单的项目Hello打开Qt后创建项目:选择New Project,接下来的根据提示即可项目创建完成后,可以看到总体的框架为:修改main.cpp的内容如下:#include "mainwindow.h"#include &lt;QApplicati...

2018-03-06 09:46:39 361

原创 Spring quick-start

1. Intellij IDEA使用入门:Intellij IDEA创建并运行java项目HelloWorld参考网址:http://blog.csdn.net/lw_power/article/details/50155073File-&gt;New-&gt;Project...,选择java,SDK自动显示系统中的JDK版本下面的库可以不需要选择点击next,什么都不需要选择新建项目,选择自己...

2018-02-24 20:39:46 511

转载 ubuntu相关配置

1.java安装:http://blog.csdn.net/williamyi96/article/details/782685952.maven安装:sudo apt-get install maven3.gradle安装:https://gradle.org/install/4.spring-boot-cli手动配置(ubuntu)参考网址:https://www.jianshu.com/p/...

2018-02-23 17:57:13 202

原创 规划问题的matlab求解

1. 线性规划matlab求解首先列出方程,matlab程序如下:%线性规划clear all;c=[2;3;1];a=[1,4,2;3,2,0];b=[8;6];%x为最优解,y为最优值[x,y]=linprog(c,-a,-b,[],[],zeros(3,1));得到的优化结果可以在下面的命令行中输出:

2018-02-02 19:35:15 1243

原创 matlab从excel和txt中读取数据

1. 从excel中读取数据2.从txt中读取数据3. 曲线拟合(1)多项式拟合'r*':r表示的是颜色,*表示用*表示三阶多项式拟合的效果较好。(2)指定函数拟合给出的数据为:matlab代码如下:%指定函数拟合方法syms t%必须使用列向量x=[0;0.4;

2018-01-31 13:58:05 6576 1

原创 ubuntu执行apt-get update遇到问题及解决

在ubuntu 16.04中执行sudo apt-get update遇到下面的问题解决方法:执行命令sudo rm /var/lib/apt/lists/lock

2018-01-23 23:21:47 3619

原创 743-Network Delay Time

类别:graph难度:medium题目描述There are N network nodes, labelled 1 to N.Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source node, v is the t

2018-01-11 18:28:50 538

原创 310-Minimum Height Trees

类别:graph难度:medium题目描述For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with

2018-01-11 10:25:18 204

原创 207-Course Schedule

类别:graph(拓扑)难度:medium题目描述There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to

2018-01-09 13:53:43 224

原创 718-Maximum Length of Repeated Array

类别:dynamic programming难度:medium题目描述Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.Example 1:Input:A: [1,2,3,2,1]B: [3,

2018-01-09 00:10:31 197

原创 523-Continuous Subarray Sum

类别:dynamic programming难度:medium题目描述Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that s

2018-01-08 15:25:26 214

原创 241-Different ways to add parentheses

类别:divide and conquer难度:medium题目描述Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The vali

2018-01-08 00:09:40 233

原创 322-Coin Change

类别:dynamic programming难度:medium动态规划01背包问题参考连接:http://blog.csdn.net/hearthougan/article/details/53749841http://blog.csdn.net/hearthougan/article/details/53869671题目描述:You are

2018-01-07 23:34:49 274

原创 01 matrix

类别:BFS难度:medium题目描述Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.The distance between two adjacent cells is 1.input;0 0 00 1 00 0 0outp

2018-01-07 00:01:28 490

原创 515-Find largest Value in Each Tree Low

类别:BFS难度:medium题目描述算法分析:因为需要确定是哪一行,所以将节点放到队列中的时候需要标识它的行号。首先,1进入队列,行号为0【】将队列中的对头节点取出,然后将其左右节点放到队列中,其左右节点的行号为父节点行号+1, 【】对于从队列中取出来的节点,记其行号为k,将该节点的数值与ans[k]比较,取较大者,当该行的节点全部遍历完即可得到该

2018-01-06 23:28:30 161

原创 659-Split Array into Consecutive Subsequences

类别:greedy难度:medium题目描述首先,需要正确理解题目的意思,最开始的时候误解为是只要将所有的数字分成两组,然后每一组中的数字含有三个以上连续的数字,后来发现并不是。题目的意思是:将数组划分为子数组,使得每个子数组中的数字都是连续无重复的并且每个子数组的长度需要大于等于三。判断是否能够进行这样的划分,可以的话返回true,否则返回false。算法分析

2018-01-06 09:27:47 223

原创 455-Assign Cookies

类别:greedy 难度:easy题目描述算法描述(1)对孩子们的最低要求进行排序,对所有的饼干进行排序 (2)将能够满足孩子要求的最小的饼干给相应的孩子,直到遍历完两个数组。代码实现class Solution {public: int findContentChildren(vector<int>& g, vector<int>& s) { int n = g.si

2018-01-04 00:04:55 170

原创 107-Binary Tree Level Order Traversal II

类别:BFS 难度:easy题目描述算法分析广度优先搜索,使用队列辅助实现,具体实现与前面一篇博客102相同,只不过是在最后的时候,将结果进行反转而已(单纯的数组的反转)代码实现class Solution {public: vector<vector<int>> levelOrderBottom(TreeNode* root) { vector<vector<int>>

2017-12-20 00:00:38 115

原创 102- Binary Tree Level Order Traversal

类别:BFS 难度:medium题目描述算法分析(1)广度优先算法,使用队列辅助实现 (2)如果单纯是从左到右,逐层遍历二叉树的话,就很简单: 最初将根节点压入队列中,在队列不为空的情况下,不断的从队头取出元素,并且将队头元素的左右节点压入队列中,知道队列为空,则遍历结束。 (4)这道题目与普通的遍历存在一个不同的地方是:需要按层进行分析,所以使用了一个level作为标记,并且压入队列中的除

2017-12-19 23:53:11 157

原创 113-Path Sum II

类别:DFS 难度:medium题目描述算法分析与112的算法基本一样,但是要注意在实现的过程中对于左子树和右子树path分别进行复制,因为if是先后进行的,第一个if判断后会在第二个if中使用path,而此时path已经发生改变代码实现class Solution {public: void findPath(vector<vector<int>>& result, vector<in

2017-12-18 21:49:45 158

原创 112-Path Sum

类别:DFS 难度:easy题目描述算法分析用递归的方式,分别对左子树和右子树存在的路径进行和进行判断。当当前节点的左右节点分别为NULL时,即路径已经到达叶子节点。代码实现bool hasPathSum(TreeNode* root, int sum) { if (root == NULL) return false; bool result = false; if (r

2017-12-18 21:42:19 176

原创 111、257(递归,DFS)

类别:recursive, DFS111-Minimum Depth of Binary Tree题目描述: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the near

2017-12-17 21:13:15 185

原创 67-add Binary

难度:easy题目描述算法分析对都有字符的进行相加,并且注意carry的值,对于不同长度的部分,与carry进行相加即可。 char转int,ch - ‘0’ int转char,int + ‘0’代码实现class Solution {public: string addBinary(string a, string b) { int n1 = a.length(),

2017-12-17 17:08:53 247

原创 66-PlusOne

难度:easy题目描述Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The di

2017-12-17 16:26:26 132

原创 50-pow(x,n)

类别:递归,二分 难度:medium算法分析如果是暴力进行循环求解的话,会超时,所以需要二分减少计算量。 对n为奇数和偶数的情况分别进行讨论: pow(x, n) = (n % 2 == 0) ? pow(x*x, n/2) : x * pow(x*x, n/2); 需要特别注意的是,因为在进行计算之前先将n转为正数,所以要考虑n = -(2^31)的情况,转为正数以后会出现溢出的情况。代码

2017-12-17 16:10:55 190

原创 45-Jump Game II

类别:BFS 难度:hard题目描述代码实现int jump(vector<int>& nums) { int n = nums.size(); if (n < 2) return 0; int level = 0, i = 0, curMax = 0, nextMax = 0; // 节点下标 while (curMax - i + 1 > 0) {

2017-12-17 14:02:30 180

原创 55-Jump Game

类别:BFS 难度:medium题目描述代码实现#include <iostream>#include <vector>using namespace std;bool canJump(vector<int>& nums) { int n = nums.size(); if (n < 2) return true; int level = 0, i = 0, curMa

2017-12-17 13:59:42 129

原创 46、47-Permutations

难度:medium题目描述46-Permutations I:47-Permutations II:算法分析46: 直接使用函数next_permutation(_vector.begin(), _vector.end()) 47: 在46题的基础上,使用二层循环,对得到的全排列两两进行比较,删除重复的排列代码实现46:// use function next_permutationcla

2017-12-15 21:16:47 179

原创 38-Count And Say

类别:string题目描述算法分析1:“1”(有1个1) 2:“11”(表示上一个即第一个有1个1,而当前有2个1) 3:“21”(表示上一个即第二个有2个1,而当前有1个2,1个1) 3:“1211”(表示上一个即第三个有1个2和1个1,而当前有1个1,1个2,2个1) 4:“111221”…… 给定数字n,需要从第一个数推到n,初始化strs[1] = “1”,然后用一个循环计算之后的

2017-12-15 20:56:03 141

原创 28-Implement strStr()(匹配字符串问题KMP算法)

类别:string题目描述算法使用暴力求解的算法效率低,出现runtime error,时间复杂度是O(nm) 可以使用string的find函数,但是具体的实现应该参考KMP算法:时间按复杂度是O(n+m): https://www.61mon.com/index.php/archives/183/(里面有详细的KMP算法介绍和代码实现,此处不做赘述)代码实现#include <iostrea

2017-12-15 20:20:36 212

空空如也

空空如也

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

TA关注的人

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