![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 66
女侠楚楚楚
这个作者很懒,什么都没留下…
展开
-
69. Sqrt(x)【leetcode解题报告】
descriptionImplement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are trunc...原创 2018-04-30 11:18:08 · 153 阅读 · 0 评论 -
347. Top K Frequent Elements【leetcode解题报告】
题目Given a non-empty array of integers, return the k most frequent elements.For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number of u...原创 2018-04-28 22:02:39 · 113 阅读 · 0 评论 -
264. Ugly Number II【 leetcode解题报告】
DescriptionWrite a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of t...原创 2018-05-07 14:27:39 · 189 阅读 · 0 评论 -
215. Kth Largest Element in an Array 【leetcode解题报告】
题目: 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, ...原创 2018-04-28 20:22:39 · 164 阅读 · 0 评论 -
【算法导论】第六章 堆 学习笔记
堆二叉堆是一个数组,可以看做一个近似完全二叉树,对于一个长度为nnn的数组给定一个数组下标i, i=0,1,2,…,n−1i, i=0,1,2,…,n−1i,~i=0,1,2,…,n-1,则: parent(i)=i/2取下界left(i)=i∗2+1right(i)=i∗2+2parent(i)=i/2取下界left(i)=i∗2+1right(i)=i∗2+2par...原创 2018-04-27 10:38:04 · 184 阅读 · 0 评论 -
【算法导论】第12、13章 二叉搜索树和红黑树 学习笔记
二叉搜索树如果二叉树中的每个节点都满足: x.left≤x.keyx.right≥x.keyx.left≤x.keyx.right≥x.keyx.left\le x.key\\x.right\ge x.key 则称这棵树为二叉搜索树BST,又称二叉查找树。BST支持许多动态集合操作,包括:SEARCH、MINIMUN、MAXMUM、PREDECESSOR、SUCCESSOR、IN...原创 2018-05-01 20:25:51 · 163 阅读 · 0 评论 -
Single Number Ⅰ Ⅱ III【 leetcode解题报告】
136. Single Number ⅠDescriptionGiven a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexi...原创 2018-05-01 14:48:43 · 443 阅读 · 0 评论 -
【算法导论】第十一章 散列表 学习笔记
散列表散列表(hash table)是实现字典操作的一种有效数据结构。尽管在最坏的情况下,在散列表中的查找一个元素的时间与链表中查找的时间相同,为O(n)O(n)O(n)。在一下合理的假设下,在散列表中查找一个元素的时间复杂度为O(1)O(1)O(1) 。在散列表中不是直接把关键字作为数组的下标,而是根据关键字计算出相应的下标。直接寻址表当关键字的全域UUU比较小时,直接寻址法是简...原创 2018-05-01 10:56:22 · 254 阅读 · 0 评论 -
209. Minimum Size Subarray Sum【leetcode解题报告】
DescriptionGiven an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead.For example, ...原创 2018-04-30 19:14:30 · 168 阅读 · 0 评论 -
81. Search in Rotated Sorted Array II【leetcode解题报告】
DescriptionSuppose 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 become [2,5,6,0,0,1,2]).You are given a target value to sear...原创 2018-04-30 17:07:23 · 164 阅读 · 0 评论 -
33. Search in Rotated Sorted Array【leetcode解题报告】
DescriptionSuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(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 sear...原创 2018-04-30 17:06:57 · 294 阅读 · 0 评论 -
367. Valid Perfect Square【leetcode解题报告】
题目Given a positive integer num, write a function which returns True if num is a perfect square else False.Note: Do not use any built-in library function such as sqrt.Example 1:Input: 16Retu...原创 2018-04-30 15:08:45 · 102 阅读 · 0 评论 -
378. Kth Smallest Element in a Sorted Matrix【leetcode解题报告】
题目Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it is the kth smallest element in the sorted order, n...原创 2018-04-28 22:32:14 · 152 阅读 · 0 评论