- 博客(26)
- 资源 (14)
- 收藏
- 关注
原创 Coding Puzzels - 64 最小的窗口子字符串
给定一个字符串S和一个字符串T,求S中的最小的窗口,其中包含了T中的字符。算法的复杂度为O(n)。 例如,S="ADOBECODEBANC", T="ABC"。最小的窗口是“BANC”。注意如果不存在覆盖了T中的所有的字符的窗口,返回空字符串。如果有多个这样的窗口,确保S中总有一个唯一的最小窗口。 package com.algo.coding.puzzles; import jav
2016-06-13 23:36:07 334
原创 Coding Puzzels - 51 没有重复字符的最长的子字符串
给定一个字符串,找出其没有重复字符的最长的子字符串。例如qpxrjxkltzvx package com.algorithm.coding.puzzles; public class NonRepeatSubstring51 { public String length(String str){ int[] count = new int[26]; for(int i = 0 ;
2016-05-25 15:01:37 234
原创 Coding Puzzles - 49
e给出一个未排序的整数数组,找出最长的连续元素序列的长度。 如: 给出[100, 4, 200, 1, 3, 2], 最长的连续元素序列是[1, 2, 3, 4]。返回它的长度:4。 你的算法必须有O(n)的时间复杂度 。 package com.algo.coding.puzzles; import java.util.HashMap; public class Long
2016-05-24 22:20:42 317
原创 微软面试100题-74
74.数组中超过出现次数超过一半的数字(数组) 题目:数组中有一个数字出现的次数超过了数组长度的一半,找出这个数字。 分析:这是一道广为流传的面试题,包括百度、微软和Google在内的多家公司都 曾经采用过这个题目。要几十分钟的时间里很好地解答这道题, 除了较好的编程能力之外,还需要较快的反应和较强的逻辑思维能力。 一个数 遇到一个不同的数,抵消两个数。
2016-05-15 19:38:38 308
原创 微软面试100题-73
73.对称字符串的最大长度(字符串)。 题目:输入一个字符串,输出该字符串中对称的子字符串的最大长度。 比如输入字符串“google”,由于该字符串里最长的对称子字符串是“goog”,因此输出4。 分析:可能很多人都写过判断一个字符串是不是对称的函数,这个题目可以看成是该函数的加强版。 package com.algo.ms; public class Symmetr
2016-05-15 18:21:30 231
原创 微软面试100题-72
72.(语法) 题目:设计一个类,我们只能生成该类的一个实例。 分析:只能生成一个实例的类是实现了Singleton模式的类型。 package com.algo.ms; public class Singleton72 { private static Singleton72 instance; private Singleton72(){ } public
2016-05-15 17:20:44 179
原创 微软面试100题-71
71.数值的整数次方(数字、运算)。 题目:实现函数double Power(double base, int exponent),求base的exponent次方。 不需要考虑溢出。 分析:这是一道看起来很简单的问题。可能有不少的人在看到题目后30秒写出如下的代码: double Power(double base, int exponent) { d
2016-05-15 17:00:51 178
原创 微软面试100题-70
70.给出一个函数来输出一个字符串的所有排列(经典字符串问题)。 take abc for example. f(n) = a + f(n-1); f(n) = b + f(n-1); arr[0] and arr[1] exchange f(n) = c + f(n-1); arr[0] and arr[2] exchange package com.algo.
2016-05-14 23:00:07 170
原创 微软面试100题-69
69.旋转数组中的最小元素(数组、算法)。 题目:把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。输入一个排好序的数组的一个旋转, 输出旋转数组的最小元素。例如数组{3, 4, 5, 1, 2}为{1, 2, 3, 4, 5}的一个旋转,该数组的最小值为1。 分析:这道题最直观的解法并不难。从头到尾遍历数组一次,就能找出最小的元素, 时间复杂度显然
2016-05-14 22:52:08 218
原创 微软面试100题-68
68.把数组排成最小的数(数组、算法)。 题目:输入一个正整数数组,将它们连接起来排成一个数,输出能排出的所有数字中最小的一个。 例如输入数组{32, 321},则输出这两个能排成的最小数字32132。 请给出解决问题的算法,并证明该算法。 分析:这是09年6月份百度的一道面试题, 从这道题我们可以看出百度对应聘者在算法方面有很高的要求。 package
2016-05-13 11:56:02 334
原创 微软面试100题-66
66.颠倒栈(栈)。 题目:用递归颠倒一个栈。例如输入栈{1, 2, 3, 4, 5},1在栈顶。 颠倒之后的栈为{5, 4, 3, 2, 1},5处在栈顶。 package com.algo.ms; import java.util.Stack; public class ReverseStack66 { public void reverse(Stack res
2016-05-12 21:44:16 175
原创 微软面试100题-64
64. 寻找丑数(运算)。 题目:我们把只包含因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数, 但14不是,因为它包含因子7。习惯上我们把1当做是第一个丑数。 求按从小到大的顺序的第1500个丑数。 分析:这是一道在网络上广为流传的面试题,据说google曾经采用过这道题。package com.algo.ms; public class UglyN
2016-05-02 23:56:53 194
原创 微软面试100题-65
65.输出1到最大的N位数(运算) 题目:输入数字n,按顺序输出从1最大的n位10进制数。比如输入3, 则输出1、2、3一直到最大的3位数即999。 分析:这是一道很有意思的题目。看起来很简单,其实里面却有不少的玄机。 package com.algo.ms; public class PrintBit { public static void main(
2016-05-02 23:18:34 165
原创 微软面试100题-61(找出数组中两个只出现一次的数字)
61.找出数组中两个只出现一次的数字(数组) 题目:一个整型数组里除了两个数字之外,其他的数字都出现了两次。 请写程序找出这两个只出现一次的数字。要求时间复杂度是O(n),空间复杂度是O(1)。 分析:这是一道很新颖的关于位运算的面试题。 package com.interview.algorithm; /* * 一个数和自己xor,返回0。1^1=0 0^0=0 1
2016-04-21 22:40:39 267
原创 微软面试100题-60
60.在O(1)时间内删除链表结点(链表、算法)。 题目:给定链表的头指针和一个结点指针,在O(1)时间删除该结点。链表结点的定义如下: struct ListNode { int m_nKey; ListNode* m_pNext; }; 函数的声明如下: void DeleteNode(ListNo
2016-04-21 21:24:38 213
原创 微软面试100题-58从尾到头输出链表
58.从尾到头输出链表(链表)。 题目:输入一个链表的头结点,从尾到头反过来输出每个结点的值。链表结点定义如下: struct ListNode { int m_nKey; ListNode* m_pNext; }; 分析:这是一道很有意思的面试题。 该题以及它的变体经常出现在各大公司的面试、笔试题中。 package co
2016-04-21 21:22:46 272
原创 微软面试100题-57 (用俩个栈实现队列)
57.用俩个栈实现队列(栈、队列)。 题目:某队列的声明如下: template class CQueue { public: CQueue() {} ~CQueue() {} void appendTail(const T& node); // append a element to tail void del
2016-04-21 21:20:55 310
原创 微软面试100题 - 56LCS
56.最长公共字串(算法、字符串)。 题目:如果字符串一的所有字符按其在字符串中的顺序出现在另外一个字符串二中, 则字符串一称之为字符串二的子串。 注意,并不要求子串(字符串一)的字符必须连续出现在字符串二中。 请编写一个函数,输入两个字符串,求它们的最长公共子串,并打印出最长公共子串。 例如:输入两个字符串BDCABA和ABCBDAB,字符串BCBA和B
2016-04-21 21:09:35 249
原创 微软面试100题 - 53
53.字符串的排列(字符串)。 题目:输入一个字符串,打印出该字符串中字符的所有排列。 例如输入字符串abc,则输出由字符a、b、c所能排列出来的所有字符串 abc、acb、bac、bca、cab和cba。 package com.algorithm.interview; import java.util.ArrayList; public class Premutat
2016-04-19 22:12:42 192
原创 微软等面试100题系列 - 45(3)
四对括号可以有多少种匹配排列方式?比如两对括号可以有两种:()()和(()) package com.interview.algorithm; import java.util.ArrayList; import java.util.List; public class LeoBracketPair { public static int bracketPermutation(i
2016-04-14 22:07:10 193
原创 微软等面试100题系列 - 45(2)
2.一个整数数组,长度为n,将其分为m份,使各份的和相等,求m的最大值 比如{3,2,4,3,6} 可以分成{3,2,4,3,6} m=1; {3,6}{2,4,3} m=2 {3,3}{2,4}{6} m=3 所以m的最大值为3 package com.interview.algorithm; public class LeverageSum { /* *
2016-04-14 22:03:09 185
原创 微软等面试100题系列 - 41
41.请修改append函数,利用这个函数实现: 两个非降序链表的并集,1->2->3 和 2->3->5 并为 1->2->3->5 另外只能输出结果,不能修改两个链表的数据。 此题,合并链表,要求将俩个非有序排列的链表,有顺序的合并。 package com.algorithm.interview; public class LinkMerge {
2016-04-12 22:43:58 320
原创 Inheritance Puzzle2
package com.citibank.aimy.example.inheritance;public class Parent1 { protected int i; public Parent1(){ i = 1; } } package com.citibank.aimy.example.inheritance;public
2009-09-07 10:41:00 366
原创 Inherinates Puzzle
public class Parent { public static int index; static{ index = 1; System.out.println("Parent"); }} public class Child extends Parent { st
2009-09-07 10:29:00 322
原创 Thread2
package com.citibank.aimy.Examples.serialize;import java.util.ArrayList;public class ProductBox { private ArrayList ls = new ArrayList(); private int index = 0; //create 4 products one t
2009-07-09 19:59:00 420
原创 Thread
package com.citibank.aimy.Examples.serialize;public class MainThread { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub ProductBox
2009-07-08 17:45:00 465
McGraw.Hill.Resumes.For.Communications.Careers.eBook-LiB.pdf
2009-07-28
Puzzles for Programmers and Pros Wrox
2009-07-28
Addison Wesley - The Java Tutorial, 3rd Edition - A Short Course on the Basics
2009-06-30
Addison Wesley - Java Network Programming and Distributed Computing
2009-06-30
Addison Wesley - Inside_Java_2_Platform_Security_Second_Edition.ShareReactor
2009-06-30
Addison Wesley - Effective Java Programming Language Guide
2009-06-30
Addison Wesley - Algorithms in Java Parts 1-4 3rd Edition
2009-06-30
For.Dummies.Java.All-In-One.Desk.Reference.For.Dummies.Apr.2005.eBook-DDU
2009-06-30
For.Dummies.Beginning.Java.Programming.for.Dummies.2nd.Edition.Apr.2005.eBook-LinG
2009-06-30
Solaris™ Performance and Tools: DTrace and MDB Techniques for Solaris 10 and OpenSolaris
2007-06-14
The.C.plus.plus.Standard.Library.Extensions.A.Tutorial.and.Reference.Jul.2006.chm
2007-05-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人