自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(105)
  • 收藏
  • 关注

原创 wsl安装zsh和配置

要安装redis,看了下windows下面实在不好搞,于是看了别人的教程打算在wsl中装一个。安装wsl过程略去安装redis在 Win10 上安装 Redis 4.0 的两种姿势sudo apt install gccwget http://download.redis.io/releases/redis-5.0.5.tar.gztar xzf redis-5.0.5.tar.gz...

2019-07-27 23:41:05 2287

原创 【LeetCode】102. Binary Tree Level Order Traversal(C++)

地址:https://leetcode.com/problems/binary-tree-level-order-traversal/题目:Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For exampl...

2019-01-03 08:58:19 286

原创 配置linux下go开发环境-Vim

新建~/.vimrc文件vim .vimrc定制当前用户的vim配置根据这个文章里的自己添加了一些配置很好很强大的vimrc(带注释版)2. 安装Vundle.vim插件参考了这篇文章,写的很详细Golang开发环境搭建-Vim篇mkdir ~/.vim/bundlegit clone https://github.com/gmarik/Vundle.vim.git ~/....

2019-01-02 16:21:17 813

原创 【LeetCode】85. Maximal Rectangle(C++)

地址:https://leetcode.com/problems/maximal-rectangle/题目:Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.Example:理解:找出给定的矩阵里全1的矩...

2019-01-02 11:05:33 332

原创 【LeetCode】84. Largest Rectangle in Histogram(C++)

地址:https://leetcode.com/problems/largest-rectangle-in-histogram/题目:Given nnn non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest ...

2019-01-01 12:05:11 272

原创 【LeetCode】76. Minimum Window Substring(C++)

地址:https://leetcode.com/problems/minimum-window-substring/题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n)O(n)O(n).Exam...

2018-12-31 11:36:13 305

原创 【LeetCode】72. Edit Distance(C++)

地址:https://leetcode.com/problems/edit-distance/题目:Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.You have the following 3 operations permi...

2018-12-29 21:51:20 259

原创 【LeetCode】442. Find All Duplicates in an Array(C++)

地址:https://leetcode.com/problems/find-all-duplicates-in-an-array/题目:Given an array of integers, 1 ≤ a[i] ≤ nnn (nnn = size of array), some elements appear twice and others appear once.Find all the ...

2018-12-28 10:15:52 156

原创 【LeetCode】45. Jump Game II(C++)

地址:https://leetcode.com/problems/jump-game-ii/题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maxi...

2018-12-27 21:42:03 223

原创 【LeetCode】696. Count Binary Substrings(C++)

地址:https://leetcode.com/problems/count-binary-substrings/题目:Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0’s and 1’s, and all the 0’s and all t...

2018-12-27 19:54:45 220

原创 【LeetCode】30. Substring with Concatenation of All Words(C++)

地址:https://leetcode.com/problems/substring-with-concatenation-of-all-words/题目:You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of sub...

2018-12-27 16:07:43 263

原创 【LeetCode】42. Trapping Rain Water(C++)

地址:https://leetcode.com/problems/trapping-rain-water/题目:Given nnn non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap afte...

2018-12-26 10:00:33 370

原创 【LeetCode】32. Longest Valid Parentheses(C++)

地址:https://leetcode.com/problems/longest-valid-parentheses/题目:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.Exa...

2018-12-22 11:00:47 217

原创 【LeetCode】23. Merge k Sorted Lists(C++)

地址:https://leetcode.com/problems/merge-k-sorted-lists/题目:Merge kkk sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:理解:合并k个有序链表。想到了外部排序里面的败者数,其本质...

2018-12-22 09:30:32 466

原创 【LeetCode】10. Regular Expression Matching(C++)

地址:https://leetcode.com/problems/regular-expression-matching/题目:Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'.‘.’ Matches any sing...

2018-12-21 12:37:31 303

原创 【go】if else踩坑

if a < 0 { fmt.Printf("a < 0\n")} else if a < 10 { fmt.Printf("a < 10\n")} else{ fmt.Printf("a >= 10\n")}就算if后面只有一行,也必须有大括号else if 和 else 不能另起一行,必须跟在}的同一行...

2018-12-20 21:37:07 449

转载 【go】ubuntu安装

Linux下安装Go环境下载安装包wget https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz安装sudo tar -C /usr/local -zxv -f go1.11.4.linux-amd64.tar.gz配置环境变量vim /etc/profileexport GOROOT=/usr/local/goe...

2018-12-20 09:59:01 559

原创 【LeetCode】4. Median of Two Sorted Arrays(C++)

地址:https://leetcode.com/problems/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 ti...

2018-12-19 10:00:08 216

原创 【LeetCode】98. Validate Binary Search Tree(C++)

地址:https://leetcode.com/problems/validate-binary-search-tree/题目:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a n...

2018-12-16 11:50:08 397

原创 【LeetCode】95. Unique Binary Search Trees II(C++)

地址:https://leetcode.com/problems/unique-binary-search-trees-ii/题目:Given an integer nnn, generate all structurally unique BST’s (binary search trees) that store values 111 … nnn.Example:理解:上一道题求的...

2018-12-16 11:06:14 701 1

原创 C++多线程库笔记2

future promise async从父线程获取子线程的变量假设有一个函数计算阶乘void factorial(int N) { int res = 1; for (int i = N; i > 1; --i) res *= i; std::cout << "result is:" << res <<

2018-12-15 11:28:18 194

原创 【LeetCode】96. Unique Binary Search Trees(C++)

地址:https://leetcode.com/problems/unique-binary-search-trees/题目:Given nnn, how many structurally unique BST’s (binary search trees) that store values 1...n1 ... n1...n?Example:理解:就是要求n个数的二叉排序树的个数...

2018-12-15 09:54:59 148

原创 【LeetCode】94. Binary Tree Inorder Traversal(C++)

地址:https://leetcode.com/problems/restore-ip-addresses/题目:Given a binary tree, return the inorder traversal of its nodes’ values.Example:理解:二叉树的中序遍历递归实现:class Solution {public: vector<int&...

2018-12-15 09:33:22 207

原创 C++多线程库笔记1

C++ 11 多线程课程介绍并发:同一时间间隔并行:同一时刻多进程:进程间通信:文件、管道、消息队列多进程:共享内存C++多线程库<thread>创建一个线程thread t(callable);其中callable为可调用对象void greeting() { cout << &amp

2018-12-14 21:17:00 407

原创 【LeetCode】93. Restore IP Addresses(C++)

地址:https://leetcode.com/problems/restore-ip-addresses/题目:Given a string containing only digits, restore it by returning all possible valid IP address combinations.Example:Input: “25525511135”Out...

2018-12-14 11:31:16 268

原创 【LeetCode】92. Reverse Linked List II(C++)

地址:https://leetcode.com/problems/reverse-linked-list-ii/题目:Reverse a linked list from position m to n. Do it in one-pass.Note: 1 ≤ m ≤ n ≤ length of list.Example:Input: 1->2->3->4->5...

2018-12-14 10:23:41 235

原创 Unix网络编程学习笔记课后题(Chapter 6)

6.1 在/usr/include/x86_64-linux-gnu/sys/select.h中查看fd_set的定义/* fd_set for select and pselect. */typedef struct { /* XPG4.2 requires this member name. Otherwise avoid the name from the ...

2018-12-11 16:58:32 425

原创 【LeetCode】91. Decode Ways(C++)

地址:https://leetcode.com/problems/decode-ways/题目:A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given a non-e...

2018-12-11 09:52:25 419

原创 【LeetCode】90. Subsets II(C++)

地址:https://leetcode.com/problems/gray-code/题目:Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).Note: The solution set must not contain...

2018-12-11 09:04:04 222

原创 Unix网络编程学习笔记课后题(Chapter 5)

5.15.2二进制文件中的0会被当做是字符串的结束,如果在读取的换行符前有一个0,会导致strlen得到的长度短于换行符所在,客户端发出了,而服务器的readline在等待换行符,导致发生了死锁。5.4 kill了服务器的进程,又发送数据,会收到一个RST,则客户端就不会再发送FIN了...

2018-12-10 20:29:04 362

原创 关于wait和waitpid

今天看了第五章,对于wait和waitpid这块一直没有搞的特别懂。自己修改了下sigchldwait.c里的方法,在循环里调用了wait。 while((pid = wait(&stat))>0) printf("child %d terminated\n", pid);然后运行tcpcli04,创建了五个子进程,第一个输入...

2018-12-10 19:44:22 209

原创 【LeetCode】89. Gray Code(C++)

地址:https://leetcode.com/problems/gray-code/题目:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer nnn representing the total num...

2018-12-10 10:24:21 257

原创 【LeetCode】86. Partition List(C++)

地址:https://leetcode.com/problems/partition-list/题目:Given a linked list and a value xxx, partition it such that all nodes less than xxx come before nodes greater than or equal to xxx.You should pres...

2018-12-10 09:06:59 228

原创 Unix网络编程学习笔记课后题(Chapter 4)

4.1 如何辨别<netinet/in.h>中定义的INADDR_是主机序还是网络序。less /usr/include/netinet/in.h可以发现是按小端序存储的,Linux的主机序就是小端序。还有个想法,可以用htonl()去转换,看结果是不是相等。4.2在connect调用返回成功后调用getsockname查看本地地址和端口号len=sizeof(clia...

2018-12-09 21:13:51 605

原创 【LeetCode】82. Remove Duplicates from Sorted List II(C++)

地址:https://leetcode.com/problems/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 li...

2018-12-09 11:41:34 166

原创 【LeetCode】81. Search in Rotated Sorted Array II(C++)

地址:https://leetcode.com/problems/search-in-rotated-sorted-array-ii/题目:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,0,1,2,2,5,6] might beco...

2018-12-09 10:23:57 208

原创 Unix网络编程学习笔记课后题(Chapter 3)

3.1因为不同类型的套接字长度不同。IPV4和IPV6套接字长度固定,但Unix域结构和数据链路结构是可变长度的,需要一个参数记录结果的大小,直接传就是值传递了,需要传一个指针,以实现引用传递。3.2void指针只能用来传参数,不能对void类型指针加减和解引用3.3匆匆忙忙按自己的理解写了下, 也不知道对不对。。先这样吧#include "../lib/unp.h"#include...

2018-12-08 22:47:19 755

原创 Unix网络编程学习笔记课后题(Chapter 2)

2.3536是IPV4的最小重组缓冲区大小576-20*22.5从令牌环发往以太网的报文不能超过以太网的MSS,而从以太网发出的报文为了避免分片,不会超出自身的MTU,因此最大的包也是1460。2.62.7 选择性确认是说确认序号的包收到,而累计确认表示前面所有的都收到。...

2018-12-08 10:26:12 464

原创 【LeetCode】80. Remove Duplicates from Sorted Array II(C++)

地址:https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/题目:Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new le...

2018-12-08 09:32:48 138

原创 【LeetCode】79. Word Search(C++)

地址:https://leetcode.com/problems/subsets/题目: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”...

2018-12-08 09:13:21 278

空空如也

空空如也

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

TA关注的人

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