![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Interview Questions
文章平均质量分 55
mitkook
Being an usual man, making something unusual!
展开
-
众数问题
How to find if a number is present >= (n / 2) times in an array of sizen? 关于这个题目,有没有时间复杂度是O(n),空间复杂度是O(1)的解?solution by swanswan @ MitBBSint number=a[0];int count=1;for (int i=1; i<n; i+转载 2012-04-01 03:10:02 · 561 阅读 · 0 评论 -
Java is Pass-by-Value, Dammit!
THIS ARTICLE CONFIRMS MY UNDERSTANDING ON JAVA. ENJOY IT.original post: http://javadude.com/articles/passbyvalue.htm----------------------------------------------------------------------------转载 2013-10-17 02:55:09 · 798 阅读 · 0 评论 -
整形数组找回路
一个整形数组,存储的是下一跳的位置,就像指针一样。比如A[0]=2 A[1]=3 A[2]=1 A[3]=1 A[4]=3就这么跳:0 2 1 3 1 3...,于是找到了一个loop,长度为2,由1、3这两个元素组成。题目就是给出这样的数组,返回loop长度。要求O(N) time,O(1) space.int findLoop(int* arr, int a原创 2013-08-24 04:31:01 · 751 阅读 · 0 评论 -
shallow copy and deep copy (浅拷贝 vs 深拷贝)
a.浅拷贝(Shallow Copy):只复制对象的基本类型,对象类型,仍属于原来的引用。 b.深拷贝(Deep Copy):不仅复制对象的基本类,同时也复制原对象中的对象.完全产生新对象。也就是说,shallow copy 只会拷贝原值,对于指针指向的内存空间,也仅仅拷贝其地址。而deep copy不仅拷贝原值,对于指针指向的内存空间,也做嵌套复制。The default cop原创 2012-10-15 08:25:50 · 732 阅读 · 0 评论 -
建堆的算法复杂度分析 O(n)
代码:template inline void MaxHeap::make_heap(vector & v) { if (heap_.size() != 0) heap_.clear(); heap_ = v; // start with last parent, and reheapify_down back to root for (int i = parent(v.size原创 2012-10-11 05:18:30 · 7346 阅读 · 2 评论 -
Career Cup 150 (version 4.0) C++ Solution (Git Repositories)
CareerCup 150 :欢迎一起解题练习,在github上建了Repositories,有兴趣就来fork吧: https://github.com/mitkook/Career-Cup-CPP-Solutions.gitThis project try to implement career cup 150 (ver. 4.0) exercises using C++.原创 2012-08-30 00:47:10 · 2778 阅读 · 0 评论 -
微软亚洲研究院提供的面试题分析
http://www.msra.cn/talks/ItemList.aspx?type=Bop转载 2012-03-22 04:11:21 · 999 阅读 · 0 评论 -
稳定排序问题,要求O(n)时间,O(1)空间
问题:微软: 给定一个 Integer Array,只有正数和负数。使让所有正数排在所有负数后面,所有正数间相对位置不变,所有负数间相对位置不变。要求 In-Place,空间复杂度 O(1)。Facebook:一个记录数组,每个记录的关键字是0,1,2三个数中的一种,要求将数组按关键字排序。要求算法是稳定排序,O(n)时间,常数空间。Amazon:一个数组,包含positive原创 2012-03-21 13:28:35 · 1555 阅读 · 0 评论 -
Longest Subarray with Equal "1" and "0"
Problem: Given an array that only contains "1" and "0", find the longest subarray which contains equal number of "1" and "0".Solution: With hash table, we can have a O(N) solution. The detail is a原创 2012-03-21 10:37:20 · 736 阅读 · 0 评论 -
maximum subarray
经典面试题Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4原创 2012-04-06 13:34:24 · 1241 阅读 · 0 评论 -
数组找missing元素
大小N的数组有 N-k个不同的数, 范围0-N, 找missing要求用O(1) space发信人: longway2008 (longway2008), 信区: JobHunting标 题: Re: 问个题:大小N的数组有 N-k个不同的数, 范围0-N, 找miss发信站: BBS 未名空间站 (Fri Apr 6 07:07:24 2012, 美东)转载 2012-04-06 23:10:58 · 924 阅读 · 0 评论 -
Edit Distance
有两个字符串s 和 u, 问最少的步数从s转换倒u。转换的方法,从s任意取一个substring,然后可以执行以下三种操作Insert one letter to any end of the string.Delete one letter from any end of the string.Change one letter into any other on转载 2012-04-04 12:25:43 · 576 阅读 · 0 评论 -
两个大数相乘
两个大数相乘 char* multiply(char*,char*);给了两个字符串,每个都是代表了一个很长的10进制表示的数比如 char str1[] = "23456789009877666555544444"char str2[] = "346587436598437594375943875943875"最后求出他们的乘积string multiply(st转载 2012-04-03 22:42:28 · 710 阅读 · 0 评论 -
找公共次数最多的点
giving lots of intervals [ai, bi], find a point intersect with the most number of intervals要nlogn的解法【 在 utar (由它) 的大作中提到: 】: 把所有ai, bi合起来排序每点保留记号标明是a还是b,2nlog(2n)(还算O(nlogn)吧),然: 后从头扫描转载 2012-04-02 23:02:32 · 777 阅读 · 0 评论 -
Rotating an array in place
发信人: swanswan (swan), 信区: JobHunting标 题: Rotating an array in place发信站: BBS 未名空间站 (Thu Mar 29 02:00:55 2012, 美东)0 1 2 3 4 5 6 7 (N=8, k=3)->3 4 5 6 7 0 1 2leetcode上那个要移动2N次,写了个只要移动N次转载 2012-04-01 00:28:26 · 450 阅读 · 0 评论 -
The Best Interview Questions for Would-be C++ Programmers
The Best Interview Questions for Would-be C++ Programmershttp://community.topcoder.com/tc?module=Static&d1=tutorials&d2=tenBestQuestionshttp://community.topcoder.com/tc?module=Static&d1=tutorials&转载 2013-10-24 13:41:37 · 867 阅读 · 0 评论