- 博客(25)
- 资源 (9)
- 收藏
- 关注
转载 Linux调度器内幕
原文链接:http://www.ibm.com/developerworks/cn/linux/l-scheduler/本文将回顾一下 Linux 2.6 的任务调度器及其最重要的一些属性。在深入介绍调度器的详细信息之前,让我们先来理解一下调度器的基本目标。什么是调度器?通常来说,操作系统是应用程序和可用资源之间的媒介。典型的资源有内存和物理设备。但是 CPU 也可以认为是一个资源
2016-06-30 22:44:18 447
原创 leetcode——Minimum Size Subarray Sum
题目:Given an array of n positive integers and a positive integers, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead.For example, given the arra
2016-06-30 13:14:10 214
原创 leetcode——Find Minimum in Rotated Sorted Array II
题目一:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exists i
2016-06-30 10:58:44 261
原创 leetcode——Find Peak Element
题目:A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks,
2016-06-30 10:47:00 310
原创 leetcode——Maximum Product Subarray
题目:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the lar
2016-06-28 21:22:17 309
原创 二叉树的最大路径和与最远结点距离
首先确定一下单路径的定义:某个结点的单路径就是只经过该结点且不同时包含其左右子树上的结点的路径一、求连接二叉树的任意两个结点的路径的最大和分析:对于二叉树上的每一个结点,求出经过它的路径的最大和,并更新这个最大和即可。经过它的最大和路径可能有三种情况:1、其左子结点的最大单路径和大于0,且其右子结点的最大单路径和大于0,那么经过该结点的最大和路径通过该结点跨过左右子树2、其左子
2016-06-25 20:58:19 4355
原创 leetcode——Maximal Rectangle
题目: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.Above is a histogram where widt
2016-06-22 11:15:21 482 2
原创 leetcode——Word Search
题目:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or verti
2016-06-21 15:02:45 386 1
原创 leetcode——Spiral Matrix
Spiral Matrix题目:Given a matrix of m x n elements (m rows,n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6
2016-06-21 13:58:54 341
原创 leetcode——First Missing Positive
题目:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses const
2016-06-21 11:50:21 201
原创 leetcode——Median of Two Sorted Arrays
题目:There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).typedef vector::iterat
2016-06-15 12:29:58 276
原创 leetcode——Container With Most Water
题目:Given n non-negative integers a1,a2, ..., an, where each represents a point at coordinate (i,ai). n vertical lines are drawn such that the two endpoints of linei is at (i, ai) and (i, 0).
2016-06-15 12:27:57 219
原创 leetcode——Next Permutation
题目:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest pos
2016-06-15 12:25:02 258
原创 leetcode——Search in Rotated Sorted Array
指导思想:二分查找 二分查找维护两个指针first和last,在迭代过程中必须保证first指向待查找元素的左边(包括待查找元素),last指向待查找元素的右边(不包括待查找元素)且first和last之间的距离变短,这一不变条件一定要至死捍卫! 本题遵循上述的原则,也可以采用二分查找的策略在旋转有序数组中进行目标查找。但是有一个注意点就是需要判断mid(first和last的
2016-06-13 22:13:06 286
转载 new与operator new
c++中有两种new,一种是new操作符另一种是operator new。new操作符是c++语言级别支持的,类似于sizeof操作符,它会做两件事:分配足够的内存以容纳对象,然后调用构造函数初始化上一步所分配的内存。operator new就是new操作符进行第一步操作调用的函数,它只为对象分配原始内存,类似于malloc。下面详细介绍operator new函数:(1)void* op
2016-06-02 23:13:47 454
原创 GDB使用简明教程
一、在编译的时候为什么要加-g如果没有-g就看不见函数名,变量名,所代替的全是运行时的内存地址。二、如何查看和使用core文件首先通过指令ulimit -a查看系统是否允许生成core文件,可以通过指令ulimit -c unlimited取消系统对core文件的限制,ulimit -c 1024指定core文件的大小。(待补充。。)三、设置断点、监控点和单
2016-06-02 22:46:38 787
原创 C++对象内存分布(包括字节对齐和虚函数表)
1、C++对象的内存分布和虚函数表: http://blog.sina.com.cn/s/blog_60e96a410100lirk.html,注意,对象中保存的是虚函数表指针,而不是虚函数表,虚函数表在编译阶段就已经生成,同类的不同对象中的虚函数指针指向同一个虚函数表,不同类对象的虚函数指针指向不同虚函数表。2、何时进行动态绑定: (1)每个类对象在被构造时不
2016-06-02 22:32:57 2182
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人