C++
文章平均质量分 68
希夏普
这个作者很懒,什么都没留下…
展开
-
Leetcode 104.Maximum Depth of Binary Tree (二叉树的最大深度)
问题描述 Given a binary tree, find its maximum depth. //The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 翻译:给定一棵二叉树,找到它的最大深度 相关概念: (1)原创 2016-10-24 22:29:04 · 427 阅读 · 0 评论 -
Leetcode 204.Count Primes 素性检测
204.Count Primes问题描述 Count the number of prime numbers less than a non-negative number, n. 翻译:计算小于一个非负数n的素数的数量解题思路 (1)最简单的方法–暴力求解 一个函数 countPrimes 算小于非负数n的素数的数量,同时在里面的循环里调用另一个bool型的函数 isPrim原创 2016-10-13 01:14:47 · 444 阅读 · 0 评论 -
Leetcode 121. Best Time to Buy and Sell Stock
问题描述 Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction, design an algorithm to find the maximum profit.原创 2016-10-25 11:10:45 · 334 阅读 · 0 评论 -
Leetcode 122 . Best Time to Buy and Sell Stock II
问题描述 Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like原创 2016-10-25 11:44:34 · 367 阅读 · 0 评论 -
整数相乘的分治算法
引言 很久很久以前,有人是这样算乘法的:x*y,好经典~ 有人是这样算复数乘法的:(a+bi)(c+di)=ac-bd+(bc+ad)i,实数乘法进行了四次,这种普通乘法时间复杂度是O(n^2)。 但是!我们伟大的数学家高斯(Gauss)发现,其实上式可以通过三个实数乘法来完成:ac, bd ,(a+b)(c+d)。 这种算法可以应用到大数相乘之中,当数小的时候这只是很小的改进,但是当数很大原创 2016-10-25 23:27:58 · 5098 阅读 · 1 评论