这道题基于的特质是,如果是一个递减序列,那么左起第一个数就是peak element,如果是递增数列,那么右侧第一个是 所以可以使用二分搜索,如果一个mid本身并不是peak element,那么它如果比右侧大的话,那么说明左侧(包括它自己)一定有一个最优解,否则右侧(不包括它自己)一定有一个最优解 ...
分类:
其他好文 时间:
2016-06-29 06:38:13
阅读次数:
130
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjac ...
分类:
其他好文 时间:
2016-06-29 06:35:41
阅读次数:
157
php安装扩展错误:Cannotfindconfig.m4.Makesurethatyourun/usr/local/bin/phpizeinthetoplevelsource故障解决:如果在安装php扩展的时候出现如题的错误:只需到php的安装目录下如:cd/source/php-5.6.11/ext/openssl执行命令:cp./config0.m4./config.m4即可解决
分类:
Web程序 时间:
2016-06-29 01:17:10
阅读次数:
220
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 comple ...
分类:
其他好文 时间:
2016-06-28 23:43:30
阅读次数:
166
题目大意: 在这个城市里有两个黑帮团伙,现在给出N个人,问任意两个人他们是否在同一个团伙输入D x y代表x于y不在一个团伙里输入A x y要输出x与y是否在同一团伙或者不确定他们在同一个团伙里 思路:并查集 #include<cstdio> #include<iostream> #include< ...
分类:
其他好文 时间:
2016-06-28 23:36:47
阅读次数:
176
Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or ...
分类:
其他好文 时间:
2016-06-28 23:29:21
阅读次数:
202
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,?1,2, ...
分类:
其他好文 时间:
2016-06-28 23:22:05
阅读次数:
190
array 0 1 2 3 4 5 6 7 change to 4 5 6 7 0 1 2 3 find the break point and return 0 算法思想: 采用二分法查找 left=0;right=length-1;mid=(left+right)/2 若A[mid]>A[lef ...
分类:
其他好文 时间:
2016-06-28 20:21:58
阅读次数:
139
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia ...
分类:
其他好文 时间:
2016-06-28 18:21:40
阅读次数:
148
题目链接:https://leetcode.com/problems/largest-divisible-subset/题目:
Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: S...
分类:
其他好文 时间:
2016-06-28 11:04:54
阅读次数:
124