- 博客(12)
- 问答 (2)
- 收藏
- 关注
原创 longest consecutive sequence
Given 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[1, 2, 3, 4].
2016-04-12 23:33:21 413
原创 remove nth node from end of list
Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked
2016-04-10 23:18:20 234
原创 merge k sorted lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.class Solution{ public: ListNode* mergeKLists(vector<ListNode*> &lists) { if (lists.
2016-04-09 23:56:16 351
原创 简单的UDP通信的例子
客户端向服务端发送字符串UDP TEST,服务器接收数据后将接收到的字符串发送回客户端udp_server.c#include <sys/types.h>#include <sys/socket.h> /*socket()/bind()*/#include <linux/in.h> /*struct sockaddr_in*/#include <string.h> /*memset
2016-04-24 09:58:27 1165
原创 IO模型
IO的方式有阻塞IO,非阻塞IO,IO复用,信号驱动,异步IO等。 1.阻塞IO 阻塞IO是最通用的IO类型,使用这种模型进行数据接收时,在数据没有到之前程序会一直等待。2.非阻塞IO 当把套接字设置为非阻塞的IO,则对每次请求,内核都不会阻塞,会立即返回; 当没有数据的时候,会返回一个错误。3.IO复用 使用IO复用模型可以在等待的时候加入超时时间,当超时时间没有到达的时候与阻
2016-04-21 16:56:20 293
转载 网络IO模型
同步(synchronous) IO和异步(asynchronous) IO,阻塞(blocking) IO和非阻塞(non-blocking)IO分别是什么,到底有什么区别?这个问题其实不同的人给出的答案都可能不同,比如wiki,就认为asynchronous IO和non-blocking IO是一个东西。这其实是因为不同的人的知识背景不同,并且在讨论这个问题的时候上下文(context)也不
2016-04-21 13:11:57 240
原创 字节序转换函数
由于主机的千差万别,主机的字节序不能做到统一,但是对于网络上传输的变量,它们的值必须有一个统一的表示方法。网络字节序是指多字节变量在网络传输时的表示方法, 网络字节序采用大端字节序的表示方法。 所以小端字节序的系统通过网络传输变量的时候需要进行字节序转换,而大端字节序的变量则不要。Linux系统提供了如下函数进行字节序的转换。#include <arpa/inet.h>uint32_t htonl
2016-04-16 11:18:32 1645
原创 字节序
字节序是由于不同的主处理器和操作系统,对大于一个字节的变量在内存中的存放顺序不同而产生的。 通常有大端字节序和小端字节序两种。例如一个16位的整数,它由两个字节构成,在有的系统上会将高字节放在内存的低地址上,而有的系统则将高字节放在内存的高地址上,所以存在字节序的问题。Little endian:将低序字节存储在起始地址 Big endian:将高序字节存储在起始地址例如变量的值为0xabcd,
2016-04-14 11:22:46 315
原创 简单的socket编程
服务端tcp_server.c:#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <sys/socket.h>#include <unistd.h>#include <linux/in.h>#define PORT 8888 //端口地址#define BAC
2016-04-13 18:13:44 283
原创 swap nodes in pairs
Given a linked list, swap every two adjacent nodes and return its head. For example, Given1->2->3->4, you should return the list as2->1->4->3. Your algorithm should use only constant space. You may
2016-04-07 23:14:49 285
原创 Makefile入门
Makefile用于多文件工程的编译例如一个简单的工程1.add.h#ifndef _ADD_H#define _ADD_Hextern int add_int(int a,int b);extern float add_float(float a, float b);#endifadd_int.cint add_int(int a, int b){ return
2016-04-02 11:28:47 267
原创 add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linke
2016-04-01 22:06:45 272
空空如也
selenium运行报错,需要的jar包都导入了
2018-03-16
如何抓取网站加密压缩后的数据?
2018-02-22
TA创建的收藏夹 TA关注的收藏夹
TA关注的人