Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:
Integers in each row are sorted from left to right.The first integer of each...
分类:
其他好文 时间:
2014-08-23 12:44:30
阅读次数:
211
http://acm.hdu.edu.cn/showproblem.php?pid=3641
学到:
1、二分求符合条件的最小值
/*====================================================
二分查找符合条件的最小值
======================================================*/
ll ...
分类:
其他好文 时间:
2014-08-22 00:25:15
阅读次数:
204
题意:
给定n长的序列 m个操作
序列默认为 1, 2, 3···n
操作1:D [l,r] 把[l,r]区间增长 :( 1,2,3,4 进行 D [1,3]变成 1,1,2,2,3,3,4 )
操作2:Q [l,r] 问区间[l,r] 上出现最多次数的数 的次数
线段树,维护每个区间的size 和叶子节点中最大的size
开始二分查找size的前缀和,逗了一场。。其实直接dfs就好了...
分类:
其他好文 时间:
2014-08-21 21:17:44
阅读次数:
345
参考文献1
参考文献2
题目:输入二叉树中的两个结点,输出这两个结点在数中最低的共同父结点
变种一:二叉树是二分查找树,如果根节点比两个节点都小,则访问右子树,都大则访问左子树,否则即为结果
变种二:每个节点有指向父节点的指针,则转变为查找两个单链表的第一个公共节点
变种三:对于普通二叉树,下面给出两种方法
方法一:二叉树的后序遍历,先看节点是否在左子树,再看右子树,然后根据左右子...
分类:
其他好文 时间:
2014-08-21 17:22:34
阅读次数:
197
Problem DescriptionA certain local trucking company would like to transport some goods on a cargo truck from one place to another. It is desirable to ...
分类:
其他好文 时间:
2014-08-21 17:03:24
阅读次数:
246
#include?<stdio.h>
int?BinSearch(int?Source[],int?size,int?key)
{
????int?low=0,?high=size-1,mid;
????while(low<=high)
????{
????????mid=(low+high)/2;
????????if(...
分类:
其他好文 时间:
2014-08-20 12:41:22
阅读次数:
155
转载请注明出处:http://blog.csdn.net/ns_code/article/details/27364557题目描写叙述:统计一个数字在排序数组中出现的次数。输入:每一个測试案例包括两行:第一行有1个整数n,表示数组的大小。1#include/*二分查找法计算key出现的次数*/int...
分类:
其他好文 时间:
2014-08-19 22:25:15
阅读次数:
213
题意:求最长上升子序列,n=100000思路:O(N^2)铁定超时啊。。。。利用贪心的思想去找答案。利用栈,每次输入数据检查栈,二分查找替换掉最小比他大的数据,这样得到的栈就是更优的。这个题目确实不错,思路很好#include #include #include #include #include ...
分类:
其他好文 时间:
2014-08-19 20:33:25
阅读次数:
267
题目:POJ 2533 Longest Ordered Subsequence
Description
A numeric sequence of ai is ordered if a1 a2 aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN)
be any sequence (ai1...
分类:
其他好文 时间:
2014-08-19 16:37:44
阅读次数:
218