码迷,mamicode.com
首页 >  
搜索关键字:算法面试    ( 461个结果
LeetCode-003 Longest Substring Without Repeating Characters
【题目】 Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the len...
分类:其他好文   时间:2014-05-15 14:40:14    阅读次数:320
LeetCode-004 Add Two Numbers
【题目】 You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Out...
分类:其他好文   时间:2014-05-15 05:13:49    阅读次数:306
leetCode-002 Median of Two Sorted Arrays
leetCode-002 Median of Two Sorted Arrays 【题目】 There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 【题意】 有两个有序的数组,找出这两数组整合后的中位数,要求时间复杂度O(nlogn)...
分类:其他好文   时间:2014-05-15 04:42:05    阅读次数:274
LeetCode-001 Two Sum
LeetCode-001 Two Sum Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2...
分类:其他好文   时间:2014-05-15 04:34:50    阅读次数:293
LeetCode-005 Longest Palindromic Substrin
【题目】 Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 【题意】 题意是找出字符串S中最长回文子串,S最长为1000,保证有唯一解 【思路】 原字符串用特殊字符#间隔,如下所示: #a...
分类:其他好文   时间:2014-05-15 03:31:25    阅读次数:299
重构二叉树
时间限制:1 秒 内存限制:32 兆 题目描述: 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并输出它的后序遍历序列。 输入: 输入可能包含多个测试样例,对于每个测试案例, 输入的第一行为一个整数n(1<=n<=1000):代表二叉树的节点...
分类:其他好文   时间:2014-05-07 06:00:58    阅读次数:443
从尾到头打印单链表
题目描述: 输入一个链表,从尾到头打印链表每个节点的值。 输入: 每个输入文件仅包含一组测试样例。 每一组测试案例包含多行,每行一个大于0的整数,代表一个链表的节点。第一行是链表第一个节点的值,依次类推。当输入到-1时代表链表输入完毕。-1本身不属于链表。 输出: 对应每个测试案例,以从尾到头的顺序输出链表每个节点的值,每个值占一行。...
分类:其他好文   时间:2014-05-07 05:28:33    阅读次数:259
替换字符串中的空格
剑指offer上的第二道题目,在九度OJ上测试通过,但还是有些问题,因为是用C语言实现的,因此,要提前开辟一个比较大的空间来存储输入的字符串。而如果在线测试系统的测试用例中字符串的长度大于该最大值的话,会报RE,但是九度OJ的测试用例没有大于我所设定的字符串的最大值。当然,这道题目用C++中的string类或java中的String类实现会更好,不需要担心输入字符串的长度。...
分类:其他好文   时间:2014-05-07 04:52:58    阅读次数:315
二分查找二维数组
剑指offer上的第一道题目,在九度OJ上测试通过 题目描述: 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 输入: 输入可能包含多个测试样例,对于每个测试案例, 输入的第一行为两个整数m和n(1<=m,n<=1000):代表将要输入的矩阵的行数和列数。 输入的第二行包括一个整数t(1<=t<=1000000):代表要查找的数字。 接下来的m行,每行有n个数,代表题目所给出的m行n列的矩...
分类:其他好文   时间:2014-05-04 18:26:36    阅读次数:348
经典白话算法之中缀表达式和后缀表达式
一、后缀表达式求值 后缀表达式也叫逆波兰表达式,其求值过程可以用到栈来辅助存储。 假定待求值的后缀表达式为:6  5  2  3  + 8 * + 3  +  *,则其求值过程如下: (1)遍历表达式,遇到的数字首先放入栈中,依次读入6 5 2 3 此时栈如下所示: (2)接着读到“+”,则从栈中弹出3和2,执行3+2,计算结果等于5,并将5压入到栈中。...
分类:其他好文   时间:2014-05-03 16:59:21    阅读次数:309
461条   上一页 1 ... 44 45 46 47 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!