自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Leader的专栏

这是一位Leader的博客

  • 博客(109)
  • 资源 (2)
  • 收藏
  • 关注

原创 合并K个有序数组(假设每个数组长度相等)

直接上代码,看注释#include using namespace std;struct HeapNode { int val;//num value int i;//array index int j;//num index};//length of each arraystatic const int numLen = 3;//adjust minheapvoid

2016-12-30 16:40:42 440 1

原创 Linux系统编程手册读书笔记——第3章 系统编程概念

系统调用系统调用使处理器从用户态切换到内核态每个系统调用都有一个唯一的数字来标识系统调用流程:参数入栈,传入外壳函数,外壳函数将参数置入特定寄存器(包括系统调用编号),执行中断指定。内核响应中断指令,调用system_call()里程处理中断。如何处理中断呢? 在内核栈保存寄存器的值审核系统调用编号的有效性通过编号找到相应的系统调用服务例程,调用时会先检查参数的有效性,然后执行任务。

2016-08-12 12:45:23 392 1

原创 Python 多线程分块读取文件

什么也不说,直接上代码,绝对看的懂# _*_coding:utf-8_*_import time, threading, ConfigParser'''Reader类,继承threading.Thread@__init__方法初始化@run方法实现了读文件的操作'''class Reader(threading.Thread): def __init__(self, f

2016-08-02 15:29:26 8620 3

转载 Longest Common Prefix

class Solution {public: string longestCommonPrefix(vector& strs) { int n = strs.size(); if(n == 0) return ""; int len = strs[0].size(); for (int i

2015-08-21 18:01:33 309

转载 Container With Most Water

class Solution {public: int maxArea(vector& height) { int len = height.size(); if (len <= 1) return 0; int begin = 0 ; int end = len-1; in

2015-08-21 17:39:56 253

转载 ZigZag Conversion

class Solution {public: string convert(string s, int nRows) { if (nRows <= 1 || s.length() == 0) return s; string res = ""; int len = s.length();

2015-08-21 16:56:14 195

原创 Add Two Numbers

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* ad

2015-08-21 15:25:47 268

转载 Two Sum

class Solution {public: vector twoSum(vector& nums, int target) { vector res(2,-1); if (!nums.empty()) { unordered_map m; for(int i = 0; i <

2015-08-21 14:59:37 244

原创 Spiral Matrix II

class Solution {public: vector> generateMatrix(int n) { vector> result(n,vector(n,0)); int circle = ceil(float(n)/2); int num = 1; for(int i = 1;i <= circle;+

2015-07-29 13:46:34 230

原创 Single Number II

class Solution {public: int singleNumber(vector& nums) { int len = nums.size(); if(len == 1) return nums[0]; sort(nums.begin(),nums.end());

2015-07-28 23:09:45 251

转载 Rotate List

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* ro

2015-07-21 17:09:58 240

转载 Longest Valid Parentheses

class Solution {public: int longestValidParentheses(string s) { const int size = s.size(); int start = -1; int res = 0; stack stackdata; for(int i=0 ;

2015-07-08 14:09:21 253

转载 Binary Tree Right Side View

/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */clas

2015-07-06 19:08:17 266

转载 Binary Tree Maximum Path Sum

/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */clas

2015-07-06 18:55:26 328

转载 Largest Number

class Solution {public: string largestNumber(vector& nums) { string m_res = ""; if (nums.size() < 1) return m_res; sort(nums.begin(),nums.end(),compare);

2015-06-30 14:14:42 269

原创 Python 多线程分块读文件

这里参考了这篇文章 https://gist.github.com/friskfly/4412375 ,然后加上自己的理解和应用, 整理如下: # -*- coding: utf-8 -*-import os,timeimport threadingimport ConfigParserrlock = threading.RLock()curPosition = 0cl

2015-06-30 10:35:42 2784 3

原创 Binary Tree Preorder Traversal

/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */clas

2015-06-24 16:48:33 423

原创 Evaluate Reverse Polish Notation

class Solution {public: int evalRPN(vector& tokens) { if(tokens.empty()) return 0; stack s; int res=0; const int n=tokens.size(); for(int

2015-06-24 16:37:05 224

原创 Intersection of Two Linked Lists

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode *ge

2015-06-24 16:06:34 246

转载 Minimum Window Substring

class Solution {public: string minWindow(string S, string T) { if (S.empty() || T.empty()) { return ""; } int count = T.size(); int require[128

2015-06-19 11:32:49 293

转载 Anagrams

class Solution {public: vector anagrams(vector& strs) { map m; vector res; if(strs.empty()) return res; const int n=strs.size();

2015-06-16 23:22:58 280

转载 Reverse Words in a String

class Solution {public: void reverseWords(string &s) { string res=""; int i=0; const int n=s.size(); while(true) { while(i<n && s[i]==' ')

2015-06-16 23:19:56 268

转载 Spiral Matrix

class Solution {public: vector spiralOrder(vector>& matrix) { vector res; if(matrix.empty()||matrix[0].empty()) return res; int m=matrix.

2015-06-16 11:16:37 238

转载 Find Peak Element

class Solution {public: int findPeakElement(vector& nums) { int low=0; int high=nums.size()-1; while(low<high) { int mid=low+(high-low)/2;

2015-06-15 11:26:34 303

转载 Maximum Subarray

class Solution {public: int maxSubArray(vector& nums) { const int n=nums.size(); int maxSum=0; //每一段的最大值,局部最优 int result=INT_MIN; //全局最优 for(int i=0;i<

2015-06-09 12:53:13 233

原创 Search for a Range

class Solution {public: vector searchRange(vector& nums, int target) { const int n=nums.size(); vector res(2,-1); int start=0;int end=n-1; while(star

2015-06-09 12:52:03 296

转载 Reverse Nodes in k-Group

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* re

2015-06-04 16:13:45 271

转载 Container With Most Water

class Solution {public: int maxArea(vector& height) { const int n=height.size(); int leftWall=height[0]; int rightWall=height[n-1]; int left=0; int ri

2015-06-04 15:42:01 228

原创 Search a 2D Matrix

class Solution {public: bool searchMatrix(vector>& matrix, int target) { const int m=matrix.size(); const int n=matrix[0].size(); int i=0; int j=n-1;

2015-06-04 15:06:37 215

原创 Remove Nth Node From End of List

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* re

2015-06-04 14:57:31 302

转载 Max Points on a Line(转载,完全转载hackersun)

/** * Definition for a point. * struct Point { * int x; * int y; * Point() : x(0), y(0) {} * Point(int a, int b) : x(a), y(b) {} * }; */class Solution {public: int maxPoi

2015-06-03 11:21:14 223

转载 Reverse Linked List II

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* re

2015-06-02 14:58:56 248

转载 Reverse Linked List

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* re

2015-06-02 10:07:49 249

转载 Remove Duplicates from Sorted List II

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* de

2015-06-02 09:47:06 543

转载 Search in Rotated Sorted Array

class Solution {public: int search(vector& nums, int target) { int low=0; int high=nums.size()-1; while(low<=high) { int mid=low+(high-low)/2;

2015-06-01 23:27:42 256

转载 Search in Rotated Sorted Array II

class Solution {public: bool search(vector& nums, int target) { int low=0; int high=nums.size()-1; while(low<=high) { int mid=low+(high-low)/2;

2015-06-01 23:27:14 269

原创 Remove Duplicates from Sorted Array II

class Solution {public: int removeDuplicates(vector& nums) { const int n=nums.size(); if(0==n) return 0; int temp=nums[0]; int length=0; f

2015-06-01 19:42:29 212

原创 Remove Duplicates from Sorted Array

class Solution {public: int removeDuplicates(vector& nums) { if(nums.empty()) return 0; const int n=nums.size(); int length=0; int temp=nums[0];

2015-06-01 16:41:14 232

转载 Maximum Subarray

class Solution {public: int maxSubArray(vector& nums) { const int n=nums.size(); int MaxSum=nums[0]; int curMax=nums[0]; for(int i=1;i<n;++i) {

2015-06-01 16:13:50 208

转载 Subsets

class Solution {public: vector> subsets(vector& nums) { vector> res; vector emp; res.push_back(emp); sort(nums.begin(),nums.end()); if(!nums.

2015-05-28 00:08:33 276

docker从入门到精通-入门篇

docker入门教程。推荐新手下载,网上找的资源,很不错

2018-01-26

opencv控件

opencv的控件程序,vc++画图必备。

2013-04-28

空空如也

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

TA关注的人

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