自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

JackyLau的专栏

Youth is not a time of life; it is a state of mind.

  • 博客(66)
  • 资源 (1)
  • 收藏
  • 关注

原创 Search for a Range

Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the target is not found in the ar

2015-11-17 16:46:47 577 1

原创 Search in Rotated Sorted Array II

Follow up for “Search in Rotated Sorted Array”: What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the array.pu

2015-11-17 16:45:51 467

原创 Search in Rotated Sorted Array

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).You are given a target value to search. If found in the array return its index

2015-11-17 16:44:51 498

原创 Search Insert Position

Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Here

2015-11-17 16:43:36 483

原创 Subsets II

Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate

2015-11-17 16:42:35 415

原创 Subsets

Given a set of distinct integers, nums, return all possible subsets.Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. For example, If

2015-11-17 16:40:10 354

原创 Two Sum

Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where in

2015-11-17 16:38:56 333

原创 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 vertically neig

2015-11-17 16:37:04 451

原创 垃圾回收器的实现

In computer science, garbage collection (GC) is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaimgarbage, or memory occupied byobjects that

2015-03-12 21:59:59 773

原创 memcpy引起的core dump

在运行实验mapcg的kmeans程序时,当means num 为256,512,1024,都出现错误,通过gdb test core文件,追踪程序定位在main.cu 137行的memcpy,具体原因还不太清楚。当means num为128时,程序运行正确。 通过思考一步一步终于把问题搞明白了,收益颇丰,所以写篇博客。由于在memcpy处dump,所以出现的原因可能如下

2015-01-07 11:47:06 9435

原创 java Queue中 remove/poll, add/offer, element/peek区别

这里简单对其重复的方法做点简单的区分。offer,add区别:一些队列有大小限制,因此如果想在一个满的队列中加入一个新项,多出的项就会被拒绝。这时新的 offer 方法就可以起作用了。它不是对调用 add() 方法抛出一个 unchecked 异常,而只是得到由 offer() 返回的 false。  poll,remove区别:remove() 和 poll() 方法都是

2015-01-06 10:03:48 72406

原创 htable实现,其中表的大小采用自适应方案

前些天看到一个不错的hash table 的不错的实现方案,该哈希表的大小能够自适应的tiaozhehng

2014-11-18 23:01:53 645

原创 linux大牛们的不带头节点的单链表

第一篇博客是阿里大牛陈皓1.http://coolshell.cn/articles/8990.html/comment-page-1#comments2.http://wordaligned.org/articles/two-star-programming

2014-11-02 20:29:10 562

原创 ipc 共享内存 shared memmory

下面laingp1.http://blog.chinaunix.net/uid-26833883-id-3230564.html2.http://blog.csdn.net/ljianhui/article/details/10253345

2014-11-01 14:06:50 867

原创 ipc 消息队列message queue

下面bok1.http://www.ibm.com/developerworks/cn/linux/l-ipc/part3/2.http://blog.csdn.net/anonymalias/article/details/9829417

2014-11-01 13:55:13 1078

原创 线程池原理并用C语言实现

工作者线程worker:即线程池中可以重复利用起来执行任务的线程,一个worker的生命周期内会不停的处理多个业务job。线程池“复用”的本质就是复用一个worker去处理多个job,“流控“的本质就是通过对worker数量的控制实现并发数的控制。通过设置不同的参数来控制worker的数量可以实现线程池的容量伸缩从而实现复杂的业务需求待处理工作job的存储队列:工作者线程workers的数量是

2014-11-01 13:31:24 6723

原创 线程私有数据的原理

1.http://blog.csdn.net/caigen1988/article/details/7901248

2014-10-27 15:46:40 608

原创 用c语言实现c++ array容器类

通过函数指针,可以巧妙实现面向duix

2014-10-27 15:38:12 2438

原创 assert.h原理以及自己的实现

1.该博客对assert.c的原理和使用方法进行了阐述

2014-10-20 19:37:06 2209

原创 cpu亲和性(affinity)以及位数组内核的实现.

1.对使用的介绍讲述的挺清晰http://www.oenhan.com/cpu-affinity2.

2014-10-17 17:30:33 1692

原创 可变参数问题以及实现简单的myprintf

1.该博客把vhttp://blog.csdn.net/hackbuteer1/article/details/7558979

2014-10-15 16:51:48 632

原创 mmap原理为啥效率比read/write效率高

http://blog.csdn.net/mg0832058/article/details/5890688http://blog.csdn.net/yinjiabin/article/details/7575653

2014-10-14 10:13:18 2607

原创 N皇后问题递归与非递归解法

参考资料:http://www.cnblogs.com/yanlingyin/archive/2011/12/19/2292041.html

2014-09-29 15:36:07 7798

原创 自己实现的getenv和getenv_r,验证线程是否可重入,即是否线程安全

UNIX高级环境编程中说到getenv函数是不可重入的,因为它用的是静态c

2014-09-25 18:10:04 3130

原创 多线程线程互斥量属性中的递归和非递归属性

多线程属性类型分为4中,正常的非递归,递归,

2014-09-25 18:06:29 2034

原创 /etc/profile配置文件的详解

1./etc/profile ,~/.bashrc, ~/.bash_file, /etc/profile.d 这几个文件的区别是啥,可能很多新人,

2014-08-26 21:50:01 19542

原创 用宏实现简单的多态 简单小技巧

#include#include#define List(X) \struct list_##X \{\ X data;\ struct list_##X *next;\}typedef char * string;int main(){ List(int) l1={1,NULL}; List(double) l2={2,NULL}; char *p=(char *)

2014-06-12 18:40:44 875

原创 图论所有的算法实现。DFS,BFS,Dijkstra,Floyd,Topsort,Kruskal,Prim,

参考资料:http://blog.csdn.net/cxllyg/article/details/7606184//http://2728green-rock.blog.163.com/blog/static/43636790200901211848284///http://blog.csdn.net/qiuyoungster/article/details/7846169

2014-06-12 12:27:35 1921

原创 数组中,只有一个/两个/三个数只有一个,其他都为偶数个,找出只有一个的数

解决方案1:先排序,后比较,时间

2014-06-12 11:20:28 965

原创 并查集

并查集是一个非常精巧的数据结果,

2014-05-30 15:46:18 648

原创 用栈实现表达式求值

以前文章中写过一个表达式求值

2014-05-30 15:30:20 1809

原创 用栈实现迷宫

C语言没有自己的栈操作的一库函数

2014-05-30 15:19:10 2577 2

原创 hash表的拉链法解决冲突

//拉链法对hash table的溢出处理#include#include#include#define MAX_CHAR 10#define TABLE_SIZE 13typedef struct element{ char key[MAX_CHAR]; //other fields}element ;typedef struct List{ element item

2014-05-30 15:15:25 1559 1

原创 hash表线性探测法

准备把最近写的一些代码一一贴出来,也算是总结吧。只能

2014-05-30 15:14:01 1270

原创 项目需要写了一个,内核红黑数代码的封装使用

/* * ============================================================================= * * Filename: rbtree.h * * Description: rbtree(Red-Black tree) implementation adapted from linux *

2014-05-30 15:06:52 774

原创 实现一个字符串中单词个数的统计,并按照单词字典序输出单词以及单词的出现个数。使用strsep

请你实现一个字符串中单词个数的统计,并按照单词字典序输出单词以及单词的出现个数。Hint:a.不考虑标点符号.b.如果有单词是大写将单词转换为小写统计c.句子中除了单词全部都是空格,没有其他特殊字符。Input:”I love you do you love me”Output:do 1I 1love 2me 1you 2

2014-05-30 15:00:38 7625

原创 strtok,strtok_r,strtsep

分割字符串的时候,一般想到用strtok,但是该函数使用时需要很小心,而且结果有的时候让人费解。比如说网上这段代码:比如,分隔符=“,” 字符串=“Fred,John,Ann”通过strtok 就可以把3个字符串 “Fred”     “John”      “Ann”提取出来。上面的C代码为QUOTE:int in=0;char buffer[]="Fre

2014-05-29 20:39:06 851

原创 fflush用法的注意事项

今天写代码的时候调试程序,老是出现段错误,通过gdb发现在用scanf

2014-04-11 14:34:09 1851

原创 二叉树的各种操作的(递归非递归)的实现,如(递归非递归)先序后序中序层次遍历 二叉树的高度 叶子节点数,所有节点数

#include#include#include#include#include"BinaryTree.h"BiTree CreateBiTree( ){ char ch=getchar(); // char ch; // scanf("%c",&ch); if( ch=='#') return NULL; else { BiTree bt=(BiTree)

2014-04-09 17:08:09 1059

原创 二叉查找树带父节点指针的创建,销毁,查找,删除,插入,找前驱后继,找最小值最大值(递归和非递归的实现)

#include#include#include#includetypedef int bool ;#define true 1#define false 0#define SWAP(x,y,t) ((t=x),(x=y),(y=t))#define INT#ifdef CHARtypedef char DataType;#elsetypedef int Da

2014-04-09 17:02:21 1131

空空如也

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

TA关注的人

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