杨氏矩阵是这样的矩阵,它的每行每列都是由小到大排序的。以前板上post了一道google的算法题,大家在杨氏矩阵第k大问题上卡住了,前段时间无意发现一个解法,感觉很不错(非 ...
用一个栈实现队列的先进先出特性
给一个很大的数组a, 再给m个查询。查询是找出在给定a的某个区间中最大的那个元素。比如a是a= {1,2,3,4,5,6,7,8,9,0} 查询是[0,3]则回答是4。设计一种算法或数据结构能最 ...
Write a function that, given a binary search tree and a value, will find the next biggest node value in the tree
Create two evenly balanced teams for a game of soccer.Condition:The difference between the number of players in both teams should not differ by more than 1 . ...
Given an array of positive and negative integers, re-arrange it so that you have postives on one end and negatives on the other, BUT retain the original ord ...
比如当n为5时,1,2,3,4,5,1出现的次数为1n为15时,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 1出现的次数为7次
Given a Sorted array S. You've to return an index i where s=i or -1 if there is no index such
In MS Excel, the column numbers are named as A, B, C, ......, Z. If you go beyond this 'Z' column you will encounter AA-->AZ, BA-->BZ, .... ZA-->ZZ then AAA-- ...
There is an array of odd and even numbers. Now, sort them in such a way that the top portion of the array contains odd numbers, bottom portion contains even n ...
给你一个没有间隔的字符串“thisisasentence”,如何将他分割成如下的句子:“this is a sentence”。提供一个函数用来检验一个字符串是不是单词:bool dic(const char* ...
Given an array A of positive integers. Convert it to a decrement array with minimum cost. The only valid operation are:Decrement with cost = 1 (only once on a ...
这个问题我见过Google问了好几次了:就是像Google和百度那种搜索关键字输入的框框,你输入一半字符串它会在下拉列表里按搜索频率高低显示关键词。比如你输入"hel",下拉框 ...
某次列车途经C个城市,城市编号依次为1到C,列车上共有S个座位,铁路局规定售出的车票只能是坐票,即车上所有的旅客都有座,售票系统是由计算机执行的,每一个售票申请包含 ...
就是给一个柱状统计图,各个小矩形宽度相等,高度不一,每一个矩形是由几个相邻柱状条条组成,矩形的高度为最短的那根条条,求所有组合中最大的矩形面积,假设柱状统计图是 ...
现在有大量的1元,2元,5元,10元,20元和50元面额的纸币,给定一个金额总数,用这些零钱找开,求一共多少种找法。比如4元有 :1111, 211, 22, 三种找法有一种快的算法 ...
n对括号可以有多少种匹配排列方式?比如两对括号可以有两种:()()和(())
Give you a expression,you can add some parenthesis to maximize result.Example as following:1 + 2 * 3 - 2Its result is 7 in the example.But you can add a par ...
以排好序的数组,找出数组最长等差数列的长度,比如1 3 5 6 8 9 10 12 13 14最长等差数列为6 8 10 12 14
判断整数序列是不是二元查找树的后序遍历结果题目:输入一个整数数组,判断该数组是不是某二元查找树的后序遍历的结果。如果是返回true,否则返回false。例如输入5、 ...