不会跑

work for life

23 Jun 2017

Python二分查找的一个库–bisect

今天在刷Leetcode的动态规划LIS题时,在提交页发现了一个返回即将插入列表的元素的下标的库bisect,下面应该是用二分查找做的,库的用法如下: In [248]: import bisect In [249]: dir(bisect...
22 Jun 2017

LeetCode-Edit_Distance

比较特殊的动态规划过程,原题链接:https://leetcode.com/problems/edit-distance/ Given two words word1 and word2, find the minimum number o...
22 Jun 2017

LeetCode-Delect_Operation_for_Two_Strings

LCS的变形题目, 只要求出两个字符串的最长公共子序列,那么最终需要进行删除操作的就是m+n-2*result。 Given two words word1 and word2, find the minimum number of ste...
22 Jun 2017

LeetCode-Best_Time_to_Buy_and_Sell_Stock

动态规划的小题目,买卖股票, 原题链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ Say you have an array for which the i...
22 Jun 2017

LeetCode-minimum_path_sum

经典的动态规划题,三种解法都是动态规划,但是最后一种空间复杂度最小,原题链接: https://leetcode.com/problems/minimum-path-sum/ Given a m x n grid filled with n...
21 Jun 2017

LeetCode-Longest_Consecutive_Sequence

题目的意思就是求出列表里最长的连续序列, 原题如下: Given an unsorted array of integers, find the length of the longest consecutive elements sequ...
21 Jun 2017

AUPE-11-线程同步及线程的Fork

线程是对进程的一种模仿,而协程(微线程)是对线程的一种模仿; 线程创建: # include "pthread_h" int pthread_create(pthread_t * restrict tidp, const p...
21 Jun 2017

APUE-8-进程控制之Fork

最近又在回顾进程的Fork知识,然后手头又有APUE,悔恨大学没有看这样的书;在进程Fork时,将会返回两次,返回值为0的为子进程,用getppid()获取的是父进程的pid;返回值为进程id(子进程的)的是父进程,getppid返回的是自...
20 Jun 2017

LeetCode-Remove_Duplicates_from_Sorted_Array

题目比较简单,就是需要你找出数组里面不同数字的个数,但是也要求把这些项搬运到nums数组的前面去 Given a sorted array, remove the duplicates in place such that each ele...
19 Jun 2017

LeetCode-power_of_three

Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any ...