Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
分类:
其他好文 时间:
2015-08-12 21:28:06
阅读次数:
125
题目:
数组中有一个数字出现的次数超过数组长度的一半,请找出这一个数字。输入一个长度为9的数组{1,2,3,2,2,2,5,4,2},
数字2在数组中出现的次数大于数组长度的一半,返回2。
这道题类似以前做过的Maximum Subarray。
按着以前的思路:
确定某一个数字,遇到相同的数字加1,遇到不同的数字减1,当累加器为0时,我们重新开始计算即可。
完成后继续判断这个数...
分类:
编程语言 时间:
2015-08-12 13:18:44
阅读次数:
160
设置:单个设置Shader.maximumLOD、全局设置Shader.globalMaximumLOD、QualitySettings里面的Maximum LODLevel 原理:小于指定值的shader和subshader才能被使用。 应用:有时候一些显卡虽然支持很多特性,但是效率很低,此时就可...
分类:
其他好文 时间:
2015-08-12 12:59:57
阅读次数:
133
题目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...
问题描述Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.解决思路1.定义Line类{slope; intercept; isVertical; isHor...
分类:
其他好文 时间:
2015-08-11 22:53:24
阅读次数:
163
August 10, 2015有二种解法, Greedy算法, 和DP算法. 二种算法都通过leetcode online judge. 贪婪算法, 花了一个小时理解代码, 修改后很好理解.Problem statement:Find the contiguous subarray within a...
分类:
其他好文 时间:
2015-08-11 09:44:20
阅读次数:
127
QestionGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, (the...
分类:
其他好文 时间:
2015-08-11 07:18:19
阅读次数:
124
Given n points
on a 2D plane, find the maximum number of points that lie on the same straight line.
分析:
任意一条直线都可以表述为
y = ax + b
假设,有两个点(x1,y1), (x2,y2),如果他们都在这条直线上则有
y1 = kx1 +b...
分类:
其他好文 时间:
2015-08-09 20:47:26
阅读次数:
98
题目描述:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [?2,1,?3,4,?...
分类:
编程语言 时间:
2015-08-09 20:16:09
阅读次数:
134
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-08-09 01:57:22
阅读次数:
134