码迷,mamicode.com
首页 >  
搜索关键字:算法面试    ( 461个结果
待字闺中之最大乘积分析
原题 一根绳子,长度为n米。将其切成几段,每一段的长度都是整数。请给出一种切法,使得切成的各段绳子之间的乘积是最大的。注意,最少要切一下的。 分析 这个题目如何一步一步的分析呢?不管切几段,总有第一段,第二段…等等。第一段的长度有哪些选择呢?可以是1、2、3...一直到n-1(至少要切一下),我们用max_prod(n)表示长度为n的绳子的切法中,乘积最大的值。那么: 1. 当...
分类:其他好文   时间:2014-09-06 16:08:23    阅读次数:224
华为2014机试试题 - 洞穴逃生
精灵王子爱好冒险,在一次探险历程中,他进入了一个神秘的山洞。在洞穴深处,精灵王子不小心触动了洞穴内暗藏的机关,整个洞穴将很快塌陷,精灵王子必须尽快逃离洞穴。精灵王子的跑步速度为17m/s,以这样的速度可能无法逃出洞穴。庆幸的是精灵王子拥有闪烁法术,可在1s内移动60m,不过每次使用闪烁法术都会消耗魔法值10点。精灵王子的魔法值恢复的速度为4点/s,只有处在原地休息状态时才能恢复。     现在已...
分类:其他好文   时间:2014-08-22 21:12:59    阅读次数:217
单链表操作系列
#include #include typedef int ElemType; //定义结点类型 typedef struct Node { ElemType data; struct Node *next; }LNode,*LinkList; //单链表的建立1,头插法建立单链表,逆序生成 LinkList LinkListCreateH() { LinkList L,p; ...
分类:其他好文   时间:2014-07-24 23:33:03    阅读次数:237
C/C++ 排序&&查找算法(面试)
一、排序1.冒泡排序 1 void BubbleSort(int array[],int n) 2 { 3 int i=0; 4 int j=0; 5 int temp=0; 6 int flag = 0; 7 for(i=0;i i;j--) /*内...
分类:编程语言   时间:2014-07-24 17:04:35    阅读次数:242
秋季面试准备(1)——atoi的实现以及C++库函数stringstream
记得去年9月28日赶到交大去听july的算法面试讲座,他给我们出的第一个题目就是用代码实现atoi,限时10mins。由于当时很久没接触编程,当堂没写出来。记得当时讲解的时候就是要我们特别注意边界条件。写程序就像砌围墙,得先把边界条件弄好。转眼一年过去了,再过几个月就要出去hunting job.....
分类:编程语言   时间:2014-07-07 10:05:41    阅读次数:279
LeetCode: Sort List [148]
【题目】 Sort a linked list in O(n log n) time using constant space complexity. 【题意】 排序一个链表,要求时间复杂度O(nlogn),使用常量空间 【思路】 nlogn的复杂度,用归并排序求解...
分类:其他好文   时间:2014-07-02 09:25:40    阅读次数:252
LeetCode: Reverse Words in a String [151]
【题目】 Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". click to show clarification. Clarification: What constitutes a word? A sequence of non-space characters constitutes a word....
分类:其他好文   时间:2014-07-02 08:34:34    阅读次数:170
LeetCode: Insertion Sort List [147]
【题目】 Sort a linked list using insertion sort. 【题意】 用插入排序方法排序链表 【思路】 直接搞...
分类:其他好文   时间:2014-07-02 08:33:49    阅读次数:200
LeetCode: Evaluate Reverse Polish Notation [150]
【题目】 Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Some examples: ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9 ["4", "13", "5", "/...
分类:其他好文   时间:2014-07-02 07:43:36    阅读次数:212
LeetCode: Max Points on a Line [149]
【题目】 Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 【题意】 给定一堆点,要求找出一条之前上的最大点数 【思路】 没什么好的方法,从每个点P出发,遍历所有的情况 从每个点P出发,斜率相同的点即为统一之前上的点 注意两种特殊情况: 1. 两个点重合(即为同一个点) ...
分类:其他好文   时间:2014-07-02 06:52:06    阅读次数:171
461条   上一页 1 ... 31 32 33 34 35 ... 47 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!