![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数学
文章平均质量分 72
liuchenjane
这个作者很懒,什么都没留下…
展开
-
Sqrt(x)
Sqrt(x)Implement int sqrt(int x).https://discuss.leetcode.com/topic/8680/a-binary-search-solution/18x的根的取值范围在[1,x/2]之间,设置left=1,right=x/2;二分搜索。class Solution {public: int mySqrt(int x)转载 2016-09-26 21:12:59 · 275 阅读 · 0 评论 -
469. Convex Polygon
469. Convex PolygonGiven a list of points that form a polygon when joined sequentially, find if this polygon is convex (Convex polygon definition).Note:There are at least 3 and at most转载 2016-12-04 19:58:18 · 1732 阅读 · 0 评论 -
矩阵链乘问题
问题描述: 给定n个矩阵的链<A1,A2,...,An><A_1,A_2,...,A_n>,矩阵AiA_i的规模为pi×pi+1(1≤i≤n)p_i \times p_{i+1}(1\le i \le n),求完全括号化的方案,使得计算乘积A1,A2,...,AnA_1,A_2,...,A_n所需标量乘法的次数最少。 递推式: m[i,j]={0,min{m[i,k]+m[k+1,j]+pi原创 2016-11-24 19:21:01 · 434 阅读 · 0 评论 -
462. Minimum Moves to Equal Array Elements II
Minimum Moves to Equal Array Elements II Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by原创 2016-11-20 21:19:20 · 656 阅读 · 0 评论 -
463. Island Perimeter
You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely原创 2016-11-20 18:55:38 · 1402 阅读 · 0 评论 -
279. Perfect Squares
279. Perfect SquaresGiven a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 1转载 2016-11-14 21:35:09 · 397 阅读 · 0 评论 -
458. Poor Pigs
458. Poor PigsThere are 1000 buckets, one and only one of them contains poison, the rest are filled with water. They all look the same. If a pig drinks that poison it will die within 15 minutes.转载 2016-11-13 21:25:07 · 3298 阅读 · 1 评论 -
365. Water and Jug Problem
365. Water and Jug ProblemYou are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure ex原创 2016-11-01 20:21:02 · 382 阅读 · 0 评论 -
367. Valid Perfect Square
367. Valid Perfect SquareGiven 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.转载 2016-10-25 09:06:04 · 295 阅读 · 0 评论 -
Pow(x, n)
Pow(x, n)思路:x^n=(x*x)^(n/2),当n为偶数;x^n=(x*x)^(n/2)*x,当n为奇数.当n为负数时,x^n=(1/x)^(-n)注意:对边界条件的处理,当n=INT_MIN时,直接取负会溢出。https://discuss.leetcode.com/topic/5425/short-and-easy-to-understand-solution转载 2016-09-26 15:58:31 · 21892 阅读 · 0 评论 -
从求逆序对和mergeSort谈起(3)
Inversion Count for an array indicates – how far (or close) the array is from being sorted. If array is already sorted then inversion count is 0. If array is sorted in reverse order that inversion coun原创 2017-02-23 09:59:57 · 438 阅读 · 0 评论