自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

紫魔戒

思绪来的快,去的也快,偶尔在这里停留

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

原创 LeetCode300. Longest Increasing Subsequence

DescriptionGiven an unsorted array of integers, find the length of longest increasing subsequence. For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest increasing subsequence is [2, 3,

2017-05-30 20:20:18 186

原创 LeetCode581. Shortest Unsorted Continuous Subarray

DescriptionGiven an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.You need

2017-05-26 18:15:46 186

原创 如何实现守护进程?

守护进程(Daemon)是运行在后台的一种特殊进程。它独立于控制终端并且周期性地执行某种任务或等待处理某些发生的事件。守护进程是一种很有用的进程。 1、守护进程最重要的特性是后台运行。 2、守护进程必须与其运行前的环境隔离开来。这些环境包括未关闭的文件描述符,控制终端,会话和进程组,工作目录以及文件创建掩模等。这些环境通常是守护进程从执行它的父进程(特别是shell)中继承下来的。 3、守护进程

2017-05-25 12:01:32 11264

原创 C++中substr函数的用法

substr用法basic_string substr( size_type pos = 0, size_type count = npos ) const; Returns a substring [pos, pos+count). If the requested substring extends past the end of the string, or if count == np

2017-05-22 14:24:21 1317

原创 LeetCode560. Subarray Sum Equals K

DescriptionGiven an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums = [1,1,1], k = 2 Output: 2 Note

2017-05-21 19:51:26 281

原创 各种排序算法C++

各种排序算法插入排序直接插入排序void InsertSort(int arr[], int len) { int i, j; int temp; for (i = 1; i < len; i++) { temp = arr[i]; for (j = i - 1; j >= 0 && arr[j] > temp; j--)

2017-05-21 16:57:44 438

原创 LeetCode566. Reshape the Matrix

DescriptionIn MATLAB, there is a very useful function called ‘reshape’, which can reshape a matrix into a new one with different size but keep its original data.You’re given a matrix represented by a t

2017-05-20 19:31:17 240

原创 LeetCode 128. Longest Consecutive Sequence

DescriptionGiven an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is

2017-05-15 15:17:18 221

原创 # 线程安全 & 线程安全函数 & 线程不安全函数

线程安全 & 线程安全函数 & 线程不安全函数  线程安全 就是多线程访问时,采用了加锁机制,当一个线程访问该类的某个数据时,进行保护,其他线程不能进行访问直到该线程读取完,其他线程才可使用。不会出现数据不一致或者数据污染。   如果每次运行结果和单线程运行的结果是一样的,而且其他的变量的值也和预期的是一样的,就是线程安全的。   一个类或者程序所提供的接口对于线程来说是原子操作或者多个线程之间

2017-05-15 07:12:57 2204

原创 Linux进程状态

Linux进程状态Linux内核中的进程状态◆运行状态(TASK_RUNNING) 指正在被CPU运行或者就绪的状态。这样的进程被成为runnning进程。运行态的进程可以分为3种情况:内核运行态、用户运行态、就绪态。◆可中断睡眠状态(TASK_INTERRUPTIBLE) 处于等待状态中的进程,一旦被该进程等待的资源被释放,那么该进程就会进入运行状态。◆不可中断睡眠状态(TASK_UN

2017-05-13 10:11:11 193

原创 C++ 4种强制类型转换

C++的四种强制类型转换为:static_cast、const_cast、reinterpret_cast和dynamic_cast 类型转换的一般形式:cast-name(expression);static_cast任何具有明确定义的类型转换,只要不包含底层const,都可以使用static_cast; double slope = static_cast(j) / i;注:

2017-05-10 07:17:33 302

原创 TCP超时重传、滑动窗口、拥塞控制、快重传和快恢复

TCP超时重传  原理是在发送某一个数据以后就开启一个计时器,在一定时间内如果没有得到发送的数据报的ACK报文,那么就重新发送数据,直到发送成功为止。   影响超时重传机制协议效率的一个关键参数是重传超时时间(RTO,Retransmission TimeOut)。RTO的值被设置过大过小都会对协议造成不利影响。   (1)RTO设长了,重发就慢,没有效率,性能差。   (2)RTO设短了,重

2017-05-08 19:33:07 6183 1

原创 LeetCode 69. Sqrt(x)

DescriptionImplement int sqrt(int x). Compute and return the square root of x.my program 思路:看似很简单的问题,可以不断的优化算法,最开始容易想到的是定义一个num使其递增,直到num*num > x,可是未考虑num*num越界的问题,后更改判断条件为num <= x/num,可以消除越界问题。但是此算

2017-05-07 20:25:05 248

原创 LeetCode543. Diameter of Binary Tree

DescriptionGiven a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path ma

2017-05-04 12:56:40 270

空空如也

空空如也

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

TA关注的人

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