
数组
acttell
这个作者很懒,什么都没留下…
展开
-
Median of Two Sorted Arrays 两个有序数组的中位数 leetcode4
https://www.cnblogs.com/grandyang/p/4465932.html原创 2019-10-16 02:04:48 · 116 阅读 · 0 评论 -
无序数组里怎么用最少次数找到最大最小值
https://blog.youkuaiyun.com/qq_37933895/article/details/98848977https://blog.youkuaiyun.com/martin_liang/article/details/38685111原创 2019-10-16 01:14:20 · 844 阅读 · 0 评论 -
leetcode Intersection of Two Arrays II 两个数组交集
http://www.cnblogs.com/grandyang/p/5533305.html原创 2018-10-02 02:34:23 · 216 阅读 · 0 评论 -
leetcode Min Cost Climbing Stairs 爬楼梯的最小损失
http://www.cnblogs.com/grandyang/p/8343874.html原创 2018-09-25 00:28:14 · 184 阅读 · 0 评论 -
大数加法
https://www.cnblogs.com/wuqianling/p/5387099.html原创 2018-09-23 14:25:50 · 326 阅读 · 0 评论 -
中位数
https://www.cnblogs.com/grandyang/p/4896673.html http://www.cnblogs.com/grandyang/p/4465932.html原创 2018-09-09 23:28:26 · 208 阅读 · 0 评论 -
leetcode Remove Duplicates from Sorted Array 有序数组去除重复
https://blog.youkuaiyun.com/s634772208/article/details/46729477 https://www.cnblogs.com/grandyang/p/4329128.html https://blog.youkuaiyun.com/sinat_35261315/article/details/78783275原创 2018-09-09 22:20:29 · 194 阅读 · 0 评论 -
CareerCup Largest Sum Submatrix 和最大子矩阵
https://www.cnblogs.com/grandyang/p/5487815.html原创 2018-09-08 23:32:51 · 203 阅读 · 0 评论 -
查找数组重复出现数字
https://www.cnblogs.com/Kobe10/p/6306183.html原创 2018-09-08 23:17:38 · 251 阅读 · 0 评论 -
leetcode Reverse Integer 数的逆序
https://blog.youkuaiyun.com/deep_kang/article/details/79611622原创 2018-09-03 08:37:36 · 404 阅读 · 0 评论 -
排序数组中绝对值最小的元素
https://blog.youkuaiyun.com/sunnyyoona/article/details/43276387原创 2018-09-03 07:44:56 · 522 阅读 · 0 评论 -
先递增后递减数组最大值
https://www.cnblogs.com/littlepanpc/p/7704776.html原创 2018-09-03 07:29:44 · 2378 阅读 · 0 评论 -
leetcode Remove Duplicates from Sorted Array 有序数组去除重复项
https://www.cnblogs.com/grandyang/p/4329128.html原创 2018-10-02 21:46:18 · 206 阅读 · 0 评论 -
LeetCode Maximal Square 最大正方形
http://www.cnblogs.com/grandyang/p/4550604.html原创 2018-10-20 21:57:54 · 224 阅读 · 0 评论 -
leetcode Climbing Stairs
http://www.mamicode.com/info-detail-298788.htmlhttps://www.cnblogs.com/zuoyuan/p/3753553.html原创 2019-05-04 21:56:13 · 194 阅读 · 0 评论 -
leetcode Container With Most Water 装最多水的容器
https://www.cnblogs.com/grandyang/p/4455109.html原创 2019-05-04 21:50:47 · 111 阅读 · 0 评论 -
leetcode First Missing Positive 首个缺失的正数
https://www.cnblogs.com/grandyang/p/4395963.html原创 2019-05-02 18:32:26 · 135 阅读 · 0 评论 -
leetcode K-th Smallest in Lexicographical Order 字典顺序的第K小
http://www.cnblogs.com/grandyang/p/6031787.html原创 2019-05-02 17:22:07 · 208 阅读 · 0 评论 -
leetcode Fizz Buzz 嘶嘶嗡嗡
https://www.cnblogs.com/grandyang/p/5966473.html原创 2019-05-02 16:09:51 · 125 阅读 · 0 评论 -
leetcode Maximal Rectangle 最大矩形
Given a 2D boolean matrix filled with False and True, find the largest rectangle containing all True and return its area.ExampleGiven a matrix:[[1, 1, 0, 0, 1],[0, 1, 0, 0, 1],[0, 0, 1, 1, 1],[...原创 2018-12-08 16:34:26 · 145 阅读 · 0 评论 -
leetcode 水塘抽样Reservoir Sampling
https://www.cnblogs.com/grandyang/p/5875509.htmlhttps://blog.youkuaiyun.com/javastart/article/details/50610868原创 2018-11-27 18:08:58 · 265 阅读 · 0 评论 -
数组中除x一次外,其他数字三次
数组A中,除了某一个数字x之外,其他数字都出现了三次,而x出现了一次。请给出最快的方法找到x。https://blog.youkuaiyun.com/morewindows/article/details/12684497原创 2018-11-27 16:37:39 · 164 阅读 · 0 评论 -
leetcode Missing Number 丢失的数字
Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example,Given nums = [0, 1, 3] return 2.Note:Your algorithm should run in lin...原创 2018-11-27 16:04:27 · 327 阅读 · 1 评论 -
LeetCode Remove Duplicates from Sorted Array 有序数组中去除重复项
https://www.cnblogs.com/grandyang/p/4329128.html原创 2018-10-21 11:13:46 · 161 阅读 · 0 评论 -
rand5()生成rand7()
https://blog.youkuaiyun.com/u010025211/article/details/49668017原创 2018-09-02 22:38:48 · 1084 阅读 · 0 评论 -
快排堆排归并
https://blog.youkuaiyun.com/morewindows/article/details/6684558 https://blog.youkuaiyun.com/morewindows/article/details/6709644/ https://blog.youkuaiyun.com/morewindows/article/details/6678165原创 2018-08-28 08:39:09 · 260 阅读 · 0 评论 -
leetcode Best Time to Buy and Sell Stock 数组中最大的数对差
题目:给定一个数组,代表每天股票的价格,买卖一次找到最大的收益。例子:输入{7,1,5,3,6,4},输出6-1=5思路:动态规划,数组中最大的数对差#include<iostream>#include<vector>using namespace std;int stock_max(vector<int>&原创 2018-06-18 22:37:05 · 161 阅读 · 0 评论 -
leetcode最长连续上升或下降子序列
题目:给定一个整数数组,请找出最长连续上升或下降子序列 样例: 给定 [5, 4, 2, 1, 3], 其最长下降连续子序列为 [5, 4, 2, 1],返回 4. 给定 [5, 1, 2, 3, 4], 其最长上升连续子序列为 [1, 2, 3, 4],返回 4.思路: 用动态规划解决。 原数组记为a,设置两个数组分别存储递增以及递减连续子序列长度,记为inc...原创 2018-06-17 21:31:31 · 1957 阅读 · 0 评论 -
python大数相乘
python大数相乘,时间复杂度O(n^2)1、把数据扔到list里然后逆转,list顺序0~n对应个位、十位...2、创建存储结果list,长度默认为两个被乘数长度之和3、按位相乘,相同竖线位置累加4、结果list从0位开始遍历,如果大于9进位5、结果逆序def mul(n1,n2): n1.reverse() n2.reverse() n3=[] p...原创 2018-04-22 13:31:13 · 8165 阅读 · 0 评论 -
插入排序
//插入排序执行过程跟踪void insert(int a[], int n){ int i, j; for (i = 1; i < n; i++) {//a[0]到a[i-1]升序,对于每个a[i],在a[0]至a[i-1]间找位置安放 for (j = i-1; j >= 0;j--) { if (a[j] <原创 2017-07-02 20:57:31 · 176 阅读 · 0 评论 -
leetcode lexicographical numbers 字典序数字
Given an integer n, return 1 - n in lexicographical order.For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9].Please optimize your algorithm to use less time and space. The input size may...原创 2018-06-17 18:01:34 · 185 阅读 · 0 评论 -
leetcode Maximum Subarray 连续子数组最大和
Find the contiguous subarray within an array which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1],the largest sum = 6.思路:动态规划经典,转移方程:...原创 2018-06-24 18:19:55 · 159 阅读 · 0 评论 -
leetcode Spiral Matrix 构造螺旋矩阵
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[[ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6,...原创 2018-06-24 15:05:25 · 193 阅读 · 0 评论 -
leetcode Spiral Matrix 螺旋输出矩阵
Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You should return [1,2,3,6,9,8,7,4,5].思路:来看第一圈,行左到右-&gt;列上到下-&gt;行右到左-&gt;列下到上,后面一直重复,来四个游标定边界,left,right,up,downwhile终止条件:le...原创 2018-06-24 09:56:57 · 513 阅读 · 0 评论 -
leetcode Search in Rotated Sorted Array 旋转数组查找某个数
Suppose a sorted array is rotated at some pivot.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found return its index, otherwise -1.assume no duplica...原创 2018-06-23 14:07:12 · 373 阅读 · 0 评论 -
leetcode Sparse Matrix Multiplication 稀疏矩阵相乘
| 1 0 0 | | 7 0 0 | | 7 0 0 |AB = | -1 0 3 | x | 0 0 0 | = | -7 0 3 | | 0 0 1 |思路:i x k维度矩阵A与 k x j维度矩阵B 相乘得i x j维度矩阵C,C[i][j]=A[i][0]*B[0][j] +... + A[i][k]*B[k][j],为...原创 2018-06-26 09:06:00 · 511 阅读 · 0 评论 -
leetcode Longest Increasing Subsequence 最长递增子序列
Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7, 101],therefore the length is 4. there may be more than one LIS combination, it is only necessary to return the le...原创 2018-06-26 09:24:22 · 137 阅读 · 0 评论 -
leetcode 74. Search a 2D Matrix
Integers in each row are sorted from left to right.The first integer of each row is greater than the last integer of the previous row.Example :Input:matrix = [ [1, 3, 5, 7], [10, 11, 16, ...原创 2018-07-01 15:32:41 · 134 阅读 · 0 评论 -
leetcode Sort Integers 快排
Given an integer array, sort it in ascending order. Use quick sort, merge sort, heap sort or any O(nlogn) algorithm.ExampleGiven [3, 2, 1, 4, 5], return [1, 2, 3, 4, 5].https://www.cnblogs.com/gr...原创 2018-08-28 08:04:54 · 441 阅读 · 0 评论 -
leetcode Kth Largest Element in an Array 数组第k大
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, return 5.No...原创 2018-08-28 08:01:00 · 220 阅读 · 0 评论