- 博客(27)
- 资源 (3)
- 收藏
- 关注
原创 LeetCode 300. Longest Increasing Subsequence
Given an unsorted array of integers, find the length of longest increasing subsequence. 题意:给你一个无序整数数组,找到最长递增子序列的长度。For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest increasing subseque...
2018-03-29 12:52:58 19558
原创 LeetCode 239. Sliding Window Maximum
Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window m...
2018-03-28 23:16:25 19595
原创 [牛客网题库] 被3整除
小Q得到一个神奇的数列: 1, 12, 123,…12345678910,1234567891011…。并且小Q对于能否被3整除这个性质很感兴趣。小Q现在希望你能帮他计算一下从数列的第l个到第r个(包含端点)有多少个数可以被3整除。输入描述: 输入包括两个整数l和r(1 <= l <= r <= 1e9), 表示要求解的区间两端。输出描述: 输出...
2018-03-28 12:15:56 19586
原创 [牛客网题库] 牛牛的背包问题
牛牛准备参加学校组织的春游, 出发前牛牛准备往背包里装入一些零食, 牛牛的背包容量为w。 牛牛家里一共有n袋零食, 第i袋零食体积为v[i]。 牛牛想知道在总体积不超过背包容量的情况下,他一共有多少种零食放法(总体积为0也算一种放法)。输入描述: 输入包括两行 第一行为两个正整数n和w(1 <= n <= 30, 1 <= w <= 2 * 10^9),表示...
2018-03-28 12:07:36 547
原创 LeetCode 287. Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, fi...
2018-03-27 01:12:54 19364
原创 LeetCode 221. Maximal Square
Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0...
2018-03-26 21:46:20 23029
原创 LeetCode 200. Number of Islands
Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume...
2018-03-25 22:20:53 19363
原创 LeetCode 152. Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest pr...
2018-03-25 17:44:33 19401
原创 LeetCode 210. Course Schedule II
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pa...
2018-03-21 12:06:41 19288
原创 LeetCode 207.Course Schedule
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a p...
2018-03-20 23:50:08 19531
原创 LeetCode 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)的情况下完成?/* 利用一快一慢两枚指针二分链表,再将链表前一半...
2018-03-18 10:48:25 19304
原创 LeetCode 206. Reverse Linked List
206. Reverse Linked List Reverse a singly linked list. Hint: A linked list can be reversed either iteratively or recursively. Could you implement both?题意:逆置一个单链表。 提示:您能否使用迭代和递归两种方法?/* ...
2018-03-17 23:29:55 13273
原创 LeetCode 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 ↘ ...
2018-03-17 21:02:35 19481
原创 LeetCode 148. Sort List
148. Sort List Sort a linked list in O(n log n) time using constant space complexity.题意:使用固定的空间复杂度对一个链表在O(n log n)时间复杂度下排序 解决思路:对于链表,不能使用交换排序,可以使用插入排序中的二路归并排序。 1. 我们可以利用一快一慢指针将链表二分,快指针每次移动2步,慢指针每...
2018-03-17 19:43:52 19447
原创 C++ 模拟List
#ifndef MYLIST_H#define MYLIST_H#include<iostream>#include<iomanip>#include<string>#include<string.h>#include<malloc.h>#include<stdlib.h>using namespace s...
2018-03-17 16:38:45 18638
原创 LeetCode 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?题意:给你一个链...
2018-03-17 16:29:30 19414
原创 LeetCode 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(1) 解题思路看代码:/** * Definition for sin...
2018-03-17 14:05:12 12519
原创 LeetCode 191. Number of 1 Bits
191. Number of 1 Bits Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11’ has binary re...
2018-03-17 00:41:19 19281
原创 LeetCode 72. Edit Distance
72. Edit Distance Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations per...
2018-03-17 00:29:31 19521
原创 LeetCode 139. Word Break
139. Word Break Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary wo...
2018-03-17 00:22:35 19380
原创 LeetCode 187. Repeated DNA Sequences
187. Repeated DNA Sequences All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: “ACGAATTCCG”. When studying DNA, it is sometimes useful to identify repeated seq...
2018-03-17 00:05:44 19309
原创 python小应用之moviepy的视频剪辑制作gif图
对视频动画的编辑可以使用python的moviepy库,官方文档: http://zulko.github.io/moviepy/ 1、进入cmd,pip install moviepy 2、使用代码#import imageio#imageio.plugins.ffmpeg.download()import moviepy.editor as mpy#视频文件的本地路径...
2018-03-11 14:47:21 33865 3
原创 C++堆排序的实现(超详细)
C++堆排序的实现完整代码分享一篇讲解堆排序基本概念的文章,很生动形象:https://mp.weixin.qq.com/s?__biz=MzIwNTc4NTEwOQ==&mid=2247484709&idx=2&sn=7bd9b16069d5a37f9ef521c33f9475641、HeapSort.h/* 初始版本,升序排序 *//* 时间复杂度O(nlbn),空间...
2018-03-11 14:03:45 25837 3
原创 C++快速排序的实现(注释超详细)
C++快速排序的实现1、QuickSort.h/* 初始版本,升序排序 *//* 时间复杂度:最好O(nlbn),平均O(nlbn),最坏0(n^2) 空间复杂度:O(lbn) 递归栈最大深度为[lbn] + 1 不稳定:情况基于每次划分选择的主元。随机化快排得到理论最坏情况的可能性仅为1/(2^n)/** 快排思想:* 1. 随机选取一个主元作为基准,从待排序记录序列左右两端...
2018-03-11 14:00:05 21277 1
原创 C++归并排序(注释超详细)
C++归并排序的实现1、MergeSort.h/* 初始版本,升序排序 *//* 时间复杂度:O(nlbn) 将n个待排序记录归并次数为lbn,一趟归并O(n) 空间复杂度:O(n) 递归栈最大深度为[lbn] + 1 ,而辅助数组大小为n 稳定:无论最好还是最坏情况时间复杂度都是O(nlbn)*/#ifndef MERGESORT_H#define MERGESORT_H...
2018-03-11 13:54:55 31706 10
原创 apue.h头文件(Unix环境高级编程第三版)的安装
配置apue.h头文件的时候,作为Linux初学者,网上的答案都是不太适用,问题百出,弄了好久总算完成!注意我使用的是Fedora26,方法同样适用于CentOS和Ubuntu1、下载源码文件进入www.apuebook.com/code3e.html单击here进行下载2、保存3、tar解压解压:$ tar -zxv -f fi
2018-03-07 15:10:01 19881 3
原创 C++ 虚函数与纯虚函数
一、C++虚函数1、什么是虚函数?(虚函数只能借助于指针或者引用来达到多态的效果)class A{public: virtual void foo()// 虚函数关键字 virtual { cout<<"A::foo() is called"<<endl; }};class B:public A{public: void foo...
2018-03-06 23:21:34 19705
json-viewer-awesome_v1.0.6.rar
2019-12-19
算术表达式求值源码+实验报告
2018-03-18
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人