自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Linux下SUID的学习

在unix环境高级编程中,获取进程的用户id有两种方法:uid_t getuid(void) //调用进程的实际用户iduid_t geteuid(void) //调用进程的有效用户id什么是有效用户id跟实际用户id,这里可能有点迷惑,在普通情况下,实际用户id就是有效用户id,其实简单来说就是有效用户id就是该程序的所有者,而实际用户id就是该程序执行时候的用户,比如某些时候需要...

2018-05-23 20:48:32 946

原创 shell 学习总结

最近在学习shell,这里总结下一些非常基础的问题即$()和${}的区别。$() 用来替换命令行,一般来说最好用``(反引号)来表示,可以在所有的unix shell上使用,移植性比较好${} 用来替换变量,变量一般不要直接用$变量名来表示,最好是用${变量名}来表示,{}用来界限变量名。...

2018-04-28 12:16:15 201

原创 LeetCode 236 Lowest Common Ancestor of a Binary Tree解题报告

Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes v ...

2018-04-27 11:07:22 228

原创 FD_CLOEXEC 详解

最近在看《UNIX环境高级编程》这本书 在看第三章有关文件描述符号的时候有些地方不懂,就是题目的FD_CLOEXEC标志,上网查了一些资料,这里写个博客记录下。一般来说进程往往会调用fork函数来执行一个子进程,调用execve()执行其他程序,这时候可能就导致子进程中存在一些无用的文件描述符问题。父进程在fork函数的时候,子进程会拷贝跟父进程一样的地址空间,包括寄存器,文件描述符...

2018-04-20 23:24:05 9217 2

原创 简单易懂的BitMap算法

面试题经常会有类似给很大的一堆连续的,不重复的无符号整数(如10亿个整数),而且是无序的,然后希望以后能频繁快速的查找某个数字是否出现在这些数字中。a) 一开始如果我们先假设不考虑内存需求,由于要频繁快速的查找数字是否存在,所以对这些数字进行排序进行二分明显是不符合要求,查询最快就是类似hash,这道题可以直接用unordered_map<unsigned int, bool>去做...

2018-04-12 10:21:40 230

原创 LeetCode94 Binary Tree Inorder Traversal

Given a binary tree, return the inorder traversal of its nodes’ values. 1 \ 2 / 3return [1,3,2].题意就是给一个二叉树,然后返回其中序遍历的结果。 用递归其实非常简单,代码如下:class Solution {public: vec...

2018-04-11 20:33:22 120

原创 单链表快排

在说链表快排的时候,我们先看普通的快排的代码void QuickSort(vector<int> &num, int left, int right){ if(left>=right) { return ; } int key=num[left]; int i=left; int j=right;...

2018-04-10 10:38:24 188

原创 C++ 函数浮点数参数问题

有以下两种方法,当调用test(0.5)会发生问题void test(int ){}void test(float ){}因为c++默认浮点数(0.5)为double 类型,所以这里调用test(0.5)导致函数即可以向int类型转换,也可以向float类型转换,会出现找不到匹配函数方法的错误。...

2018-03-29 10:30:11 750

原创 LeetCode70 Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Input:2Output:2题意是给一个n层的阶梯,每...

2018-03-29 10:10:00 105

原创 LeetCode85 Maximal Rectangle 解题报告

Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1...

2018-03-27 23:52:45 169

原创 LeetCode84 Largest Rectangle in Histogram 解题报告

Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.题意是:给一个连续的非负整数数组,求出该数组的直方图所能组成的面积最大的长方形。如图...

2018-03-27 10:43:12 157

原创 LeetCode49 Group Anagrams解题报告

题意: 给一个字符串数组,将这个字符串按照组成的字母进行分组。 如["eat", "tea", "tan", "ate", "nat", "bat"], [ ["ate", "eat","tea"], ["nat","tan"], ["bat"]

2018-03-26 21:46:58 138

原创 LeetCode50 Pow(x, n) 解题报告

题目的意思是实现一个pow 函数。Input: 2.00000, 10Output: 1024.00000这里用的是递归的办法,能够降低时间复杂度,不过需要对n进行奇数,偶数进行判断,用了&0x1进行判断,当判断n为奇数的时候,乘上x。代码如下:class Solution {public: double myPow(double x, int n) {...

2018-03-26 21:29:42 177

原创 "Cast from pointer to smaller type 'int' loses information” 解决

线程池代码上,往往需要输出对应的线程池编号,即(int) pthread_self() 但是在64为机器上可能导致因为int为4字节,指针统统为8字节,所以一般将int改成uintptr_t 即可解决...

2018-03-03 13:47:03 7437

原创 LeetCode92 Reverse Linked List II 解题报告

Reverse a linked list from position m to n. Do it in-place and in one-pass.example:1->2->3->4->5->6 2 51->5->4->3->2->6题意是: 给出一个链表,将位置n和m的两个点之间进行旋转(包括n, m)。不能修改节...

2018-03-01 12:56:02 136

原创 LeetCode88 Merge Sorted Array 解题报告

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.题意:给定两个有序数组:nums1 和nums2,将两个数组合为一个,其中nums1有足够的空间容纳两个数组。如果不创建新的数组,那么就直接在nums1上处理,只需要在空间末尾一次次地保留nums1数组末尾和...

2018-03-01 11:09:11 131

原创 LeetCode82 Remove Duplicates from Sorted List II 解题报告

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1->

2018-01-26 17:29:55 169

原创 LeetCode83 Remove Duplicates from Sorted List解题报告

Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.题意: 就是给一个链表,去除里面重复的元素。解题

2018-01-26 17:22:05 147

原创 LeetCode72 Edit Distance 解题报告

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:

2018-01-19 15:50:03 163

原创 LeetCode74 Search a 2D Matrix 解题报告

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right. The first integer of each row

2018-01-18 18:16:04 177

原创 LeetCode71 Simplify Path 解题报告

Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"题意是给一个关于路径字符串,进行简化,得到最基本的路径字符串。这是一道基于字符串的题目,同时必须知道一些路径的基本

2018-01-15 21:47:20 149

原创 LeetCode70 Climbing Stairs 解题报告

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive

2018-01-12 16:30:53 136

原创 LeetCode67 Add Binary 解题报告

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".题意是给两个二进制字符串进行相加,返回相加的值,类型为string。这类用字符串来进行求和操作,主要是要字符串相加的时候,要先从两个字符串末尾开始,然后用一个值来保

2018-01-11 21:16:52 114

原创 LeetCode65 Valid Number 解题报告

Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguous. You

2018-01-11 20:35:39 159

原创 关于delete this

在类的成员函数中能不能使用delete this?答:能!在某些设计模式中需要赋予对象自我销毁的能力,这个时候就可以使用delete this将该对象的this指针进行删除,但是需要确定的是不能在访问该对象的数据成员,或需要调用访问这些成员的函数,虽然还是可以访问,但数据已经是不安全的。使用delete this的注意事项: 1.通常情况下delete this 往往是跟对象指针一起使用

2018-01-10 22:57:37 3202

原创 LeetCode64 minPathSum 解题报告

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at a

2018-01-10 22:45:59 359

原创 LeetCode63 Unique Paths II 解题报告

Follow up for “Unique Paths”:Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the grid.

2018-01-10 19:28:26 151

原创 LeetCode62 Unique Paths 解题报告

LeetCode62 Unique Paths 解题报告A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The r

2018-01-09 19:08:30 177

原创 LeetCode61 Rotate List 解题报告

LeetCode61 Rotate List 解题报告Given a list, rotate the list to the right by k places, where k is non-negative.题目的意思是: 在一个列表中找到倒数第k个的节点,然后进行旋转,即将该节点作为头节点,将该节点前的节点连接到最好的节点。例子: Given 1->2->3->4->5

2018-01-09 16:20:22 168

原创 unity开发-飞机大战

这个项目主要是练习下unity的一些操作,熟悉这个开发工具,顺便总结下。其中unity版本是5.3.6。导入素材: 是导入游戏里面的素材,都是在project窗口里面有个assets文件夹,直接把素材拖进去就行了。因为这是个二维游戏,建议直接把scene改成2d的。 游戏背景: 在导航栏选择GameObject->3D->Plane,新建一个plane面板,可以在inspector进行修改一些

2016-08-14 15:02:56 1291

原创 MAC OSX mpi安装

系统: osx 10.11.4openmpi版本: 1.6.5(我用2.0.0版本发现一个orte_init错误,这个不知道具体是什么问题,查资料也说是版本的问题,具体不清楚)第一步 上openmpi下载openmpi1.6.5版本第二步 解压第三步 cd到解压的文件夹,执行 ./configure第四部 执行make all 然后执行sudo make install完成安装

2016-08-11 22:14:18 3048

CADseePlus-x86

一个小程序,很多人应该都会要用到的,虽然只能看,不过还是很方便

2013-09-25

空空如也

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

TA关注的人

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