- 博客(54)
- 资源 (4)
- 收藏
- 关注
原创 Unix网络编程:第二章 传输层:TCP、UDP和SCTP
第二章 传输层:TCP、UDP和SCTP 2.1 概述 UDP是一个简单的、不可靠的数据报协议 TCP是一个复杂、可靠的字节流协议。 SCTP与TCP类似,是可靠传输协议,但它还提供消息边界、传输级别多宿(multihoming)支持以及将头端阻塞(head-of-line blocking)减少到最小的一种方法。我们必须了解由这些传输层协议提供给应用进程的服务,这样才能弄清这些协议处理什么
2017-01-21 11:28:35
541
原创 LeetCode 1. Two Sum
题目: Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example:Given nums = [2, 7,
2017-01-21 10:01:50
307
原创 2017年年度计划
2017年年度计划熟练掌握C++ 精读《C++Primer》 精读《深入探索C++对象模型》熟练掌握STL+boost 查阅书籍+源码阅读掌握一门新语言 Java/PythonCSDN博客访问量达到10W+GitHub提交开源代码换一份新工作,C++后端服务器开发/大数据/云计算熟练掌握Linux编程 APUE+UNP 重点掌握多线程编程+网络编程阅读计算机书籍,夯实基础
2017-01-21 09:49:03
388
原创 LeetCode 485. Max Consecutive Ones
Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutive 1s.
2017-01-20 22:02:23
628
原创 LeetCode 6. ZigZag Conversion
The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H NA P L S I I G
2017-01-20 15:49:16
281
原创 LeetCode 9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.分析: 1. 如果将数字转化为字符串,再判断是否为回文字符串,要使用额外空间,不满足要求。 2. 考虑将数字翻转,(LeetCode 7. Reverse Integer )[http://blog.csdn.net/teffi/article/d
2017-01-20 14:19:06
259
原创 LeetCode 8. String to Integer (atoi)
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.N
2017-01-20 10:57:41
457
原创 LeetCode 7. Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321分析:注意溢出情况。class Solution {public: int reverse(int x) { int digit = 0; int sign = 1;
2017-01-19 22:33:07
368
原创 LeetCode 136. Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra me
2017-01-17 00:50:27
242
原创 LeetCode 138. Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.分析:见《剑指offer》面试题:26 复杂链表的复制。/** * Defi
2017-01-17 00:40:01
304
原创 LeetCode 445. Add Two Numbers II
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it
2017-01-16 21:48:02
478
原创 147. Insertion Sort List
Sort a linked list using insertion sort./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */cl
2017-01-15 23:28:06
250
原创 148. Sort List
Sort a linked list in O(n log n) time using constant space complexity.分析:归并排序,考虑链表和数组的区别,链表每次划分为两段链表,然后有序链表归并。可以复用21. Merge Two Sorted Lists代码。/** * Definition for singly-linked list. * struct ListNo
2017-01-15 22:38:20
218
原创 160. Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘ c1
2017-01-15 21:36:15
242
原创 234. Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.Follow up: Could you do it in O(n) time and O(1) space?分析: 反转链表法,将链表后半段原地翻转,再将前半段、后半段依次比较,判断是否相等,时间复杂度O(n),空间复杂度为O(1)满足题目要求。/** * Definit
2017-01-15 19:26:19
234
原创 143. Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes’ values.For example, Given {1,2,3,4}, reorder it to {1,4,2,3}
2017-01-15 18:43:43
253
原创 142. Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up: Can you solve it without using extra space?解题思路:当 fast 与 s
2017-01-15 18:06:25
268
原创 109. Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNo
2017-01-15 17:51:53
235
原创 92. Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note: Given m, n satisfy the following co
2017-01-15 17:10:00
239
原创 25. Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked list. If the number of nod
2017-01-15 16:38:34
281
原创 23. Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.解题思路:复用21. Merge Two Sorted Lists的代码,链表两两合并,直到最后只剩一个链表为止。/** * Definition for singly-linked list. * s
2017-01-14 11:00:51
387
转载 我是一个网卡
原创 2016-06-16 刘欣 码农翻身 我出生在深圳的一家工厂,然后飘洋过海来到美国,被安装到一个电脑里, 然后这个电脑又漂洋过海, 被运到了中国。我知道我的使命就是传递信件,但有一个前提:我需要知道对方的地址才行,其实我们网卡都有一个全球唯一的地址,这个地址一出生就确定了,就像你们人类的身份证一样,终生不变。 无论我走到哪里,我都拥有这个唯一的标志:11:27:F5: 8A:79:54 ,
2017-01-14 10:49:27
450
原创 82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example, Given 1->2->3->3->4->4->5, return 1->2->5. Given 1->1->1->2
2017-01-14 10:34:38
314
转载 TCP/IP 之 大明王朝邮差
原创 2016-05-12 刘欣 码农翻身前言: 本文主要想说一下TCP的知识, 比喻有不恰当之处,敬请包涵。大明王朝天启四年, 清晨。 天色刚蒙蒙亮,我就赶着装满货物的马车来到了南城门, 这里是集中处理货物的地方 , 一队一队的马车都来到这里, 城头的士兵带着头盔,身披盔甲, 手持长枪, 虎视眈眈的注视这下面的动静。 城门口的大棚里乱哄哄的,是一群人围在一起赌钱, 这些家伙都穿着同样的衣服, 前
2017-01-13 10:45:01
336
原创 66. Plus One
Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digits are st
2017-01-10 23:51:53
320
原创 203. Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.Example Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6 Return: 1 –> 2 –> 3 –> 4 –> 5Credits: Special thanks to @mithmatt for a
2017-01-10 00:03:55
271
原创 328. Odd Even Linked List
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in plac
2017-01-09 23:10:53
397
原创 237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, t
2017-01-09 22:58:52
267
原创 86. Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of the
2017-01-09 22:51:28
295
原创 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?解题思路:最好的方法是时间复杂度 O(n),空间复杂度 O(1) 的。设置两个指针,一个快一个慢,快 的指针每次走两步,慢的指针每次走一步,如果快指针和慢指针相遇,则说明有环。/**
2017-01-09 22:40:53
267
原创 61. Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative.For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL.解题思路:先遍历一遍,得出链表长度 len,注意 k 可能大于 len,因此令 k%
2017-01-09 22:33:04
230
原创 83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3./** * Definition for singly-lin
2017-01-09 22:20:17
279
原创 24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example, Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You may no
2017-01-09 21:58:38
238
原创 15. 3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain duplic
2017-01-09 21:43:15
211
原创 206. Reverse Linked List
Reverse a singly linked list.解题思路:利用头节点,头插法。/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *
2017-01-09 00:04:16
206
原创 21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.解题思路:合并两个有序列表。/** * Definition for singly-linked list. * s
2017-01-08 23:13:54
283
原创 19. 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 lis
2017-01-08 22:59:37
214
原创 167. Two Sum II - Input array is sorted
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers suc
2017-01-08 19:44:35
216
原创 283. Move Zeroes
Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your funct
2017-01-08 01:11:37
213
原创 27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.The order
2017-01-08 01:04:01
238
关于Java的几个经典问题
2010-01-21
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人