hadoop简介140个Google面试问题

文/张巡

  在说Hadoop之前,作为一个铁杆粉丝先粉一下Google。Google的伟大之处不仅在于它建立了一个强悍的搜索引擎,它还创造了几项革命性的技术:GFS,MapReduce,BigTable,即所谓的Google三驾马车。Google虽然没有公布这几项技术的实现代码,但它发表了详细的设计论文,这给业界带来了新鲜气息,很快就出现了类似于Google三驾马车的开源实现,Hadoop就是其中的一个。

  关于MapReduce  

  Hadoop说起来很简单,一个存储系统(HDFS),一个计算系统(MapReduce)。仅此而已。模型虽然简单,但我觉得它的精妙之处也就在这里。目前,通过提高CPU主频来提升计算性能的时代已经结束了,因此并行计算、分布式计算在业界发展了起来,但是这也往往意味着复杂的设计与实现,如果能找到一种方法,只需要写简单的程序就能实现分布式计算,那就太好了。

  我们可以回想下当初做的课堂作业,它可能是一个处理数据的程序,没有多线程,没有进程间通信,数据输入都是来自键盘(stdin),处理完数据之后打印到屏幕(stdout),这时的程序非常简单。后来我们学习了多线程、内存管理、设计模式,写出的程序越来越大,也越来越复杂。但是当学习使用Hadoop时,我们发现又回到了最初,尽管底层是一个巨大的集群,可是我们操作文件时就像在本地一样简单,写MapReduce程序时也只需要在单线程里实现数据处理。

  Hadoop就是这样一个东西,简单的文件系统(HDFS),简单的计算模型(MapReduce)。这其中,我觉得HDFS是很自然的东西,如果我们自己实现一个,也很可能是这样的。但是仔细琢磨下MapReduce,会发现它似乎是个新奇事物,不像HDFS的界面那样通俗易懂老少皆宜。MapReduce虽然模型简单,却是一个新的、不广为人所知的概念。比如说,如果说要简化计算,为何要做成Map和Reduce两个阶段,而不是一个函数足矣呢?另外,它也不符合我们耳熟能详的那些设计模式。一句话,MapReduce实在太另类了。

  Hadoop的思想来源于Google的几篇论文,Google的那篇MapReduce论文里说:Our abstraction is inspired by the map and reduce primitives present in Lisp and many other functional languages。这句话提到了MapReduce思想的渊源,大致意思是,MapReduce的灵感来源于函数式语言(比如Lisp)中的内置函数map和reduce。函数式语言也算是阳春白雪了,离我们普通开发者总是很远。简单来说,在函数式语言里,map表示对一个列表(List)中的每个元素做计算,reduce表示对一个列表中的每个元素做迭代计算。它们具体的计算是通过传入的函数来实现的,map和reduce提供的是计算的框架。不过从这样的解释到现实中的MapReduce还太远,仍然需要一个跳跃。再仔细看,reduce既然能做迭代计算,那就表示列表中的元素是相关的,比如我想对列表中的所有元素做相加求和,那么列表中至少都应该是数值吧。而map是对列表中每个元素做单独处理的,这表示列表中可以是杂乱无章的数据。这样看来,就有点联系了。在MapReduce里,Map处理的是原始数据,自然是杂乱无章的,每条数据之间互相没有关系;到了Reduce阶段,数据是以key后面跟着若干个value来组织的,这些value有相关性,至少它们都在一个key下面,于是就符合函数式语言里map和reduce的基本思想了。

  这样我们就可以把MapReduce理解为,把一堆杂乱无章的数据按照某种特征归纳起来,然后处理并得到最后的结果。Map面对的是杂乱无章的互不相关的数据,它解析每个数据,从中提取出key和value,也就是提取了数据的特征。经过MapReduce的Shuffle阶段之后,在Reduce阶段看到的都是已经归纳好的数据了,在此基础上我们可以做进一步的处理以便得到结果。这就回到了最初,终于知道MapReduce为何要这样设计。

  Hadoop, More and More

  Hadoop/MapReduce的Job是一个昙花一现的东西,它仅仅是一个计算过程而已,所有数据都是从HDFS来,到HDFS去。当最后一个Reduce完成之后,整个Job就消失了,只在历史日志中还保存着它曾经存在的证据。

  Hadoop中的节点是对等的,因此每个节点都是可替代的。也因此,JobTracker可以把任务分配到任何一个节点执行,而不影响最后的产出结果。如果不是这样,就破坏了Hadoop的对等性。对等性可以说是Hadoop扩展能力、容错能力的基础,它意味着计算不再局限于单个节点的能力。当然事情总有两面性,对等性造成的结果是,如果我们想让某些节点做特殊的事情,会发现很困难。

  就像很多分布式系统中的文件、对象一样,Hadoop对数据的操作是原子性的,一个Job跑完之后,最终的数据是在一瞬间呈现的,如果Job失败了,则什么都没有,连部分数据也得不到。由于Job中的task都是并行的,因此这里适用于木桶理论,最后一个完成的那个task决定了整个Job完成的时刻。所以如果Hadoop发现某些Task特别慢,会在其它节点运行这些Task的副本,当其中某个副本完成后,Hadoop将Kill掉其余的副本,这也是基于对等性的一个应用,使得那些慢的节点不会拖慢Job。如果某个task在重试若干次之后仍然失败了,那么整个Job宣告失败。

  Hadoop包括HDFS、MapReduce,此外还有Hbase、Hive等,普通的应用大概是存储海量的数据,并进行批量的处理、数据挖掘等,不过也有些比较巧妙的实际应用,比如用Hadoop搭建HTTP下载服务器,或FTP服务器等,还有人用Hadoop搭建视频点播服务器。我觉得Hadoop对这些应用的最大价值是可以降低硬件成本,以前也许需要购买昂贵的硬件,现在购买廉价的服务器就可以实现。不过,做这些应用都需要对Hadoop做定制,修改代码啥的,似乎还没有整体的解决方案。

  Hadoop是Java写的。可能有不少人会想,如果Hadoop是用C或C++写的,会不会更快些?关于这个问题网上也有不少讨论,简单地说就是,不会更快。而且我觉得需要强调的一点是,当面对Hadoop要面对的问题域时,编程语言不是首先要考虑的问题,或者说,依赖于具体的实现方案。Hadoop要处理的是大批量数据,它强调的是吞吐量,当整个集群跑起来之后,系统的瓶颈往往是在磁盘IO和网络IO,这种情况下,用C/C++实现Hadoop不见得比Java实现性能更高。相反,由于Java语言的严谨、统一和一些高级特性,用Java实现Hadoop对开发者而言会更容易。一般来讲,无论是用C++写还是用Java写,当系统发展较成熟时,都已经经过了相当的优化,这时系统的瓶颈往往不在于软件了,而在于硬件的限制。当然,这并非意味着目前Hadoop已经实现得很好了,Hadoop还有很大的优化空间,它的开发进程依然火爆,很多人在优化Hadoop,还包括用C++来改写Hadoop的部分代码的。另外,对于超大的集群(比如几千台服务器),调度器的优化也很关键,否则它就可能成为整个集群的瓶颈。我想这就是Hadoop虽然已经广泛应用,但是版本号依然还是零点几的原因吧。

  虽说Hadoop的模型很简单,但是开发Hadoop的Job并不容易,在业务逻辑与HadoopAPI之间,我们还必须写大量的胶水代码,这无异于在WindowsSDK基础上写一个画图板程序,或者在Linux系统调用基础上写一个支持多用户在线的聊天服务器,这些似乎都不难,但是比较繁琐,需要堆砌大量代码,写完一个之后,你大概不会再写第二个。我把这种情况称为用汇编语言写程序,也就是说,你面对的是业务问题,却必须不遗巨细与机器打交道。

  面对上述困境,人们想出了很多解决办法,开发出高级语言来屏蔽底层的细节,让开发过程更加简单,我把这种情况称为用脚本写程序,可以很快的修改&调试。其中Facebook开发了Hive,这是类似于SQL的脚本语言,开发者基本上只要面对自己的业务数据,就能写出Hive脚本,虽然有一定的入门门槛,但是比起用HadoopAPI写程序,可以称得上是巨简单了。另外Yahoo开发了PIG-latin,也是类SQL的脚本语言,Hive和PIG都有很广泛的应用

某猎头收集了140多个Google的面试题,都张到他的Blog中了,主要是下面这些职位的,因为被墙,且无任何敏感信息,所以,我原文搬过来了。
  • Product Marketing Manager
  • Product Manager
  • Software Engineer
  • Software Engineer in Test
  • Quantitative Compensation Analyst
  • Engineering Manager
  • AdWords Associate

这篇Blog例举了Google用来面试下面这几个职位的面试题。很多不是很容易回答,不过都比较经典与变态,是Google,Microsoft,Amazon之类的公司的风格。对于本文,我没有翻译,因为我相信,英文问题是最好的。不过对于有些问题,我做了一些注释,不一定对,但希望对你有帮助启发。对于一些问题,如果你百思不得其解,可以Google一下,StackOverflow或是Wikipedia上可能会给你非常全面的答案。

Product Marketing Manager
  • Why do you want to join Google?
  • What do you know about Google’s product and technology?
  • If you are Product Manager for Google’s Adwords, how do you plan to market this?
  • What would you say during an AdWords or AdSense product seminar?
  • Who are Google’s competitors, and how does Google compete with them?
  • Have you ever used Google’s products? Gmail?
  • What’s a creative way of marketing Google’s brand name and product?
  • If you are the product marketing manager for Google’s Gmail product, how do you plan to market it so as to achieve 100 million customers in 6 months?
  • How much money you think Google makes daily from Gmail ads?
  • Name a piece of technology you’ve read about recently. Now tell me your own creative execution for an ad for that product.
  • Say an advertiser makes $0.10 every time someone clicks on their ad. Only 20% of people who visit the site click on their ad. How many people need to visit the site for the advertiser to make $20?
  • Estimate the number of students who are college seniors, attend four-year schools, and graduate with a job in the United States every year.
Product Manager
  • How would you boost the GMail subscription base?
  • What is the most efficient way to sort a million integers?  (陈皓:merge sort)
  • How would you re-position Google’s offerings to counteract competitive threats from Microsoft?
  • How many golf balls can fit in a school bus? (陈皓:这种题一般来说是考你的解题思路的,注意,你不能单纯地把高尔夫球当成一个小立方体,其是一个圆球,堆起来的时候应该是错开的——也就是三个相邻的球的圆心是个等边三角形)
  • You are shrunk to the height of a nickel and your mass is proportionally reduced so as to maintain your original density. You are then thrown into an empty glass blender. The blades will start moving in 60 seconds. What do you do?
  • How much should you charge to wash all the windows in Seattle?
  • How would you find out if a machine’s stack grows up or down in memory?
  • Explain a database in three sentences to your eight-year-old nephew. (陈皓:用三句话向8岁的侄子解释什么是数据库,考你的表达能力了)
  • How many times a day does a clock’s hands overlap?(陈皓:经典的时钟问题)
  • You have to get from point A to point B. You don’t know if you can get there. What would you do?
  • Imagine you have a closet full of shirts. It’s very hard to find a shirt. So what can you do to organize your shirts for easy retrieval? (陈皓:很不错的一道题,不要以为分类查询很容易,想想图书馆图书的分类查询问题吧。另外,你处想想如何在你在你的衣柜里实现一个相当于Hash表或是一个Tree之类的数据结构)
  • Every man in a village of 100 married couples has cheated on his wife. Every wife in the village instantly knows when a man other than her husband has cheated, but does not know when her own husband has. The village has a law that does not allow for adultery. Any wife who can prove that her husband is unfaithful must kill him that very day. The women of the village would never disobey this law. One day, the queen of the village visits and announces that at least one husband has been unfaithful. What happens? (陈皓:这个问题很有限制级,哈哈,非常搞的一个问题,注意wife们的递归,这类的问题是经典的分布式通讯问题,上网搜 一搜吧。)
  • In a country in which people only want boys, every family continues to have children until they have a boy. If they have a girl, they have another child. If they have a boy, they stop. What is the proportion of boys to girls in the country?(陈皓:第一反应是——这个国家是中国。一个概率问题,其实,无论你怎么生,50%的概率是永远不变的。)
  • If the probability of observing a car in 30 minutes on a highway is 0.95, what is the probability of observing a car in 10 minutes (assuming constant default probability)?
  • If you look at a clock and the time is 3:15, what is the angle between the hour and the minute hands? (The answer to this is not zero!)
  • Four people need to cross a rickety rope bridge to get back to their camp at night. Unfortunately, they only have one flashlight and it only has enough light left for seventeen minutes. The bridge is too dangerous to cross without a flashlight, and it’s only strong enough to support two people at any given time. Each of the campers walks at a different speed. One can cross the bridge in 1 minute, another in 2 minutes, the third in 5 minutes, and the slow poke takes 10 minutes to cross. How do the campers make it across in 17 minutes?(陈皓:经典的过桥问题)
  • You are at a party with a friend and 10 people are present including you and the friend. your friend makes you a wager that for every person you find that has the same birthday as you, you get $1; for every person he finds that does not have the same birthday as you, he gets $2. would you accept the wager?
  • How many piano tuners are there in the entire world?
  • You have eight balls all of the same size. 7 of them weigh the same, and one of them weighs slightly more. How can you find the ball that is heavier by using a balance and only two weighings?(陈皓:经典的称重问题。这样的问题花样很多,不过都不难回答)
  • You have five pirates, ranked from 5 to 1 in descending order. The top pirate has the right to propose how 100 gold coins should be divided among them. But the others get to vote on his plan, and if fewer than half agree with him, he gets killed. How should he allocate the gold in order to maximize his share but live to enjoy it? (Hint: One pirate ends up with 98 percent of the gold.)
  • You are given 2 eggs. You have access to a 100-story building. Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100th floor. Both eggs are identical. You need to figure out the highest floor of a 100-story building an egg can be dropped without breaking. The question is how many drops you need to make. You are allowed to break 2 eggs in the process. (陈皓:Binary Search,二分查)
  • Describe a technical problem you had and how you solved it.
  • How would you design a simple search engine?
  • Design an evacuation plan for San Francisco.
  • There’s a latency problem in South Africa. Diagnose it. (陈皓:这个问题完全是在考你的解决问题的能力。没有明确的答案。不过,解决性能问题的第一步通常是找出瓶颈,找瓶颈有很多种方法,工具,二分查,时间记录等等。)
  • What are three long term challenges facing Google?
  • Name three non-Google websites that you visit often and like. What do you like about the user interface and design? Choose one of the three sites and comment on what new feature or project you would work on. How would you design it?
  • If there is only one elevator in the building, how would you change the design? How about if there are only two elevators in the building? (陈皓:经典的电梯设计问题,这种问题千变万化,主要是考你的设计能力和需求变化的适变能力,与此相似的是酒店订房系统。)
  • How many vacuum’s are made per year in USA?
Software Engineer
  • Why are manhole covers round? (陈皓:为什么下水井盖是圆的?这是有N种答案的,上Wiki看看吧)
  • What is the difference between a mutex and a semaphore? Which one would you use to protect access to an increment operation?
  • A man pushed his car to a hotel and lost his fortune. What happened? (陈皓:脑筋急转弯?他在玩大富翁游戏?!!)
  • Explain the significance of “dead beef”.(陈皓:要是你看到的是16进制 DEAD BEEF,你会觉得这是什么?IPv6的地址?)
  • Write a C program which measures the the speed of a context switch on a UNIX/Linux system.
  • Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7.(陈皓:上StackOverflow看看吧,经典的问题)
  • Describe the algorithm for a depth-first graph traversal.
  • Design a class library for writing card games. (陈皓:用一系列的类来设计一个扑克游戏,设计题)
  • You need to check that your friend, Bob, has your correct phone number, but you cannot ask him directly. You must write a the question on a card which and give it to Eve who will take the card to Bob and return the answer to you. What must you write on the card, besides the question, to ensure Bob can encode the message so that Eve cannot read your phone number?(陈皓:协议+数字加密,我试想了一个,纸条上可以这样写,“Bob,请把我的手机号以MD5算法加密后的字符串,比对下面的字符串——XXXXXX,它们是一样的吗?”)
  • How are cookies passed in the HTTP protocol?
  • Design the SQL database tables for a car rental database.
  • Write a regular expression which matches a email address. (陈皓:上StackOverflow查相当的问题吧。)
  • Write a function f(a, b) which takes two character string arguments and returns a string containing only the characters found in both strings in the order of a. Write a version which is order N-squared and one which is order N.(陈皓:算法题,不难,不说了。一个O(n^2)和一个O(n)的算法复杂度)
  • You are given a the source to a application which is crashing when run. After running it 10 times in a debugger, you find it never crashes in the same place. The application is single threaded, and uses only the C standard library. What programming errors could be causing this crash? How would you test each one? (陈皓:和随机数有关系?或是时间?)
  • Explain how congestion control works in the TCP protocol.
  • In Java, what is the difference between final, finally, and finalize?
  • What is multithreaded programming? What is a deadlock?
  • Write a function (with helper functions if needed) called to Excel that takes an excel column value (A,B,C,D…AA,AB,AC,… AAA..) and returns a corresponding integer value (A=1,B=2,… AA=26..).
  • You have a stream of infinite queries (ie: real time Google search queries that people are entering). Describe how you would go about finding a good estimate of 1000 samples from this never ending set of data and then write code for it.
  • Tree search algorithms. Write BFS and DFS code, explain run time and space requirements. Modify the code to handle trees with weighted edges and loops with BFS and DFS, make the code print out path to goal state.
  • You are given a list of numbers. When you reach the end of the list you will come back to the beginning of the list (a circular list). Write the most efficient algorithm to find the minimum # in this list. Find any given # in the list. The numbers in the list are always increasing but you don’t know where the circular list begins, ie: 38, 40, 55, 89, 6, 13, 20, 23, 36. (陈皓:循环排序数组的二分查找问题)
  • Describe the data structure that is used to manage memory. (stack)
  • What’s the difference between local and global variables?
  • If you have 1 million integers, how would you sort them efficiently? (modify a specific sorting algorithm to solve this)
  • In Java, what is the difference between static, final, and const. (if you don’t know Java they will ask something similar for C or C++).
  • Talk about your class projects or work projects (pick something easy)… then describe how you could make them more efficient (in terms of algorithms).
  • Suppose you have an NxN matrix of positive and negative integers. Write some code that finds the sub-matrix with the maximum sum of its elements.(陈皓:以前见过一维数组的这个问题,现在是二维的。感觉应该是把二维的第一行的最大和的区间算出来,然后再在这个基础之上进行二维的分析。思路应该是这个,不过具体的算法还需要想一想)
  • Write some code to reverse a string.
  • Implement division (without using the divide operator, obviously).(陈皓:想一想手算除法的过程。)
  • Write some code to find all permutations of the letters in a particular string.
  • What method would you use to look up a word in a dictionary? (陈皓:使用排序,哈希,树等算法和数据结构)
  • Imagine you have a closet full of shirts. It’s very hard to find a shirt. So what can you do to organize your shirts for easy retrieval?
  • You have eight balls all of the same size. 7 of them weigh the same, and one of them weighs slightly more. How can you fine the ball that is heavier by using a balance and only two weighings?
  • What is the C-language command for opening a connection with a foreign host over the internet?
  • Design and describe a system/application that will most efficiently produce a report of the top 1 million Google search requests. These are the particulars: 1) You are given 12 servers to work with. They are all dual-processor machines with 4Gb of RAM, 4x400GB hard drives and networked together.(Basically, nothing more than high-end PC’s) 2) The log data has already been cleaned for you. It consists of 100 Billion log lines, broken down into 12 320 GB files of 40-byte search terms per line. 3) You can use only custom written applications or available free open-source software.
  • There is an array A[N] of N numbers. You have to compose an array Output[N] such that Output[i] will be equal to multiplication of all the elements of A[N] except A[i]. For example Output[0] will be multiplication of A[1] to A[N-1] and Output[1] will be multiplication of A[0] and from A[2] to A[N-1]. Solve it without division operator and in O(n).(陈皓:注意其不能使用除法。算法思路是这样的,把output[i]=a[i]左边的乘积 x a[i]右边的乘积,所以,我们可以分两个循环,第一次先把A[i]左边的乘积放在Output[i]中,第二次把A[i]右边的乘积算出来。我们先看第一次的循环,使用迭代累积的方式,代码如下:for(r=1; i=0; i<n-1; i++){ Output[i]=r; r*=a[i]; },看明白了吧。第二次的循环我就不说了,方法一样的。)
  • There is a linked list of numbers of length N. N is very large and you don’t know N. You have to write a function that will return k random numbers from the list. Numbers should be completely random. Hint: 1. Use random function rand() (returns a number between 0 and 1) and irand() (return either 0 or 1) 2. It should be done in O(n).(陈皓:本题其实不难。在遍历链表的同时一边生成随机数,一边记录最大的K个随机数和其链接地址。)
  • Find or determine non existence of a number in a sorted list of N numbers where the numbers range over M, M>> N and N large enough to span multiple disks. Algorithm to beat O(log n) bonus points for constant time algorithm.(陈皓:使用bitmap,如果一个长整形有64位,那么我们可以使用M/64个bitmap)
  • You are given a game of Tic Tac Toe. You have to write a function in which you pass the whole game and name of a player. The function will return whether the player has won the game or not. First you to decide which data structure you will use for the game. You need to tell the algorithm first and then need to write the code. Note: Some position may be blank in the game। So your data structure should consider this condition also.
  • You are given an array [a1 To an] and we have to construct another array [b1 To bn] where bi = a1*a2*…*an/ai. you are allowed to use only constant space and the time complexity is O(n). No divisions are allowed.(陈皓:前面说过了)
  • How do you put a Binary Search Tree in an array in a efficient manner. Hint :: If the node is stored at the ith position and its children are at 2i and 2i+1(I mean level order wise)Its not the most efficient way.(陈皓:按顺序遍历树)
  • How do you find out the fifth maximum element in an Binary Search Tree in efficient manner. Note: You should not use use any extra space. i.e sorting Binary Search Tree and storing the results in an array and listing out the fifth element.
  • Given a Data Structure having first n integers and next n chars. A = i1 i2 i3 … iN c1 c2 c3 … cN.Write an in-place algorithm to rearrange the elements of the array ass A = i1 c1 i2 c2 … in cn(陈皓:这个算法其实就是从中间开始交换元素,代码:for(i=n-1; i>1; i++) {  for(j=i; j<2*n-i; j+=2) { swap(a[j], a[j+1]); } },不好意思写在同一行上了。)
  • Given two sequences of items, find the items whose absolute number increases or decreases the most when comparing one sequence with the other by reading the sequence only once.
  • Given That One of the strings is very very long , and the other one could be of various sizes. Windowing will result in O(N+M) solution but could it be better? May be NlogM or even better?
  • How many lines can be drawn in a 2D plane such that they are equidistant from 3 non-collinear points?
  • Let’s say you have to construct Google maps from scratch and guide a person standing on Gateway of India (Mumbai) to India Gate(Delhi). How do you do the same?
  • Given that you have one string of length N and M small strings of length L. How do you efficiently find the occurrence of each small string in the larger one?
  • Given a binary tree, programmatically you need to prove it is a binary search tree.
  • You are given a small sorted list of numbers, and a very very long sorted list of numbers – so long that it had to be put on a disk in different blocks. How would you find those short list numbers in the bigger one?
  • Suppose you have given N companies, and we want to eventually merge them into one big company. How many ways are theres to merge?
  • Given a file of 4 billion 32-bit integers, how to find one that appears at least twice? (陈皓:我能想到的是拆分成若干个小数组,排序,然后一点点归并起来)
  • Write a program for displaying the ten most frequent words in a file such that your program should be efficient in all complexity measures.(陈皓:你可能需要看看这篇文章Finding Frequent Items in Data Streams
  • Design a stack. We want to push, pop, and also, retrieve the minimum element in constant time.
  • Given a set of coin denominators, find the minimum number of coins to give a certain amount of change.(陈皓:你应该查看一下这篇文章:Coin Change Problem
  • Given an array, i) find the longest continuous increasing subsequence. ii) find the longest increasing subsequence.(陈皓:这个题不难,O(n)算法是边遍历边记录当前最大的连续的长度。)
  • Suppose we have N companies, and we want to eventually merge them into one big company. How many ways are there to merge?
  • Write a function to find the middle node of a single link list. (陈皓:我能想到的算法是——设置两个指针p1和p2,每一次,p1走两步,p2走一步,这样,当p1走到最后时,p2就在中间)
  • Given two binary trees, write a compare function to check if they are equal or not. Being equal means that they have the same value and same structure.(陈皓:这个很简单,使用递归算法。)
  • Implement put/get methods of a fixed size cache with LRU replacement algorithm.
  • You are given with three sorted arrays ( in ascending order), you are required to find a triplet ( one element from each array) such that distance is minimum. Distance is defined like this : If a[i], b[j] and c[k] are three elements then distance=max(abs(a[i]-b[j]),abs(a[i]-c[k]),abs(b[j]-c[k]))” Please give a solution in O(n) time complexity(陈皓:三个指针,a, b, c分别指向三个数组头,假设:a[0]<b[0]<c[0],推进a直到a[i]>b[0],计算 abs(a[i-1] – c[0]),把结果保存在min中。现在情况变成找 a[i], b[0],c[0],重复上述过程,如果有一个新的值比min要小,那就取代现有的min。)
  • How does C++ deal with constructors and deconstructors of a class and its child class?
  • Write a function that flips the bits inside a byte (either in C++ or Java). Write an algorithm that take a list of n words, and an integer m, and retrieves the mth most frequent word in that list.
  • What’s 2 to the power of 64?
  • Given that you have one string of length N and M small strings of length L. How do you efficiently find the occurrence of each small string in the larger one? (陈皓:我能想到的是——把那M个小字串排个序,然后遍历大字串,并在那M个字串中以二分取中的方式查找。)
  • How do you find out the fifth maximum element in an Binary Search Tree in efficient manner.
  • Suppose we have N companies, and we want to eventually merge them into one big company. How many ways are there to merge?
  • There is linked list of millions of node and you do not know the length of it. Write a function which will return a random number from the list.
  • You need to check that your friend, Bob, has your correct phone number, but you cannot ask him directly. You must write a the question on a card which and give it to Eve who will take the card to Bob and return the answer to you. What must you write on the card, besides the question, to ensure Bob can encode the message so that Eve cannot read your phone number?
  • How long it would take to sort 1 trillion numbers? Come up with a good estimate.
  • Order the functions in order of their asymptotic performance: 1) 2^n 2) n^100 3) n! 4) n^n
  • There are some data represented by(x,y,z). Now we want to find the Kth least data. We say (x1, y1, z1) > (x2, y2, z2) when value(x1, y1, z1) > value(x2, y2, z2) where value(x,y,z) = (2^x)*(3^y)*(5^z). Now we can not get it by calculating value(x,y,z) or through other indirect calculations as lg(value(x,y,z)). How to solve it?
  • How many degrees are there in the angle between the hour and minute hands of a clock when the time is a quarter past three?
  • Given an array whose elements are sorted, return the index of a the first occurrence of a specific integer. Do this in sub-linear time. I.e. do not just go through each element searching for that element.
  • Given two linked lists, return the intersection of the two lists: i.e. return a list containing only the elements that occur in both of the input lists. (陈皓:把第一个链表存入hash表,然后遍历第二个链表。不知道还没有更好的方法。)
  • What’s the difference between a hashtable and a hashmap?
  • If a person dials a sequence of numbers on the telephone, what possible words/strings can be formed from the letters associated with those numbers?(陈皓:这个问题和美国的电话有关系,大家可以试着想一下我们发短信的手机,按数字键出字母,一个组合的数学问题。)
  • How would you reverse the image on an n by n matrix where each pixel is represented by a bit?
  • Create a fast cached storage mechanism that, given a limitation on the amount of cache memory, will ensure that only the least recently used items are discarded when the cache memory is reached when inserting a new item. It supports 2 functions: String get(T t) and void put(String k, T t).
  • Create a cost model that allows Google to make purchasing decisions on to compare the cost of purchasing more RAM memory for their servers vs. buying more disk space.
  • Design an algorithm to play a game of Frogger and then code the solution. The object of the game is to direct a frog to avoid cars while crossing a busy road. You may represent a road lane via an array. Generalize the solution for an N-lane road.
  • What sort would you use if you had a large data set on disk and a small amount of ram to work with?
  • What sort would you use if you required tight max time bounds and wanted highly regular performance.
  • How would you store 1 million phone numbers?(陈皓:试想电话是有区段的,可以把区段统一保存,Flyweight设计模式)
  • Design a 2D dungeon crawling game. It must allow for various items in the maze – walls, objects, and computer-controlled characters. (The focus was on the class structures, and how to optimize the experience for the user as s/he travels through the dungeon.)
  • What is the size of the C structure below on a 32-bit system? On a 64-bit? (陈皓:注意编译器的对齐)

struct foo {

char a;
char* b;
};
Software Engineer in Test
  • Efficiently implement 3 stacks in a single array.
  • Given an array of integers which is circularly sorted, how do you find a given integer.
  • Write a program to find depth of binary search tree without using recursion.
  • Find the maximum rectangle (in terms of area) under a histogram in linear time.
  • Most phones now have full keyboards. Before there there three letters mapped to a number button. Describe how you would go about implementing spelling and word suggestions as people type.
  • Describe recursive mergesort and its runtime. Write an iterative version in C++/Java/Python.
  • How would you determine if someone has won a game of tic-tac-toe on a board of any size?
  • Given an array of numbers, replace each number with the product of all the numbers in the array except the number itself *without* using division.
  • Create a cache with fast look up that only stores the N most recently accessed items.
  • How to design a search engine? If each document contains a set of keywords, and is associated with a numeric attribute, how to build indices?
  • Given two files that has list of words (one per line), write a program to show the intersection.
  • What kind of data structure would you use to index annagrams of words? e.g. if there exists the word “top” in the database, the query for “pot” should list that.
Quantitative Compensation Analyst
  • What is the yearly standard deviation of a stock given the monthly standard deviation?
  • How many resumes does Google receive each year for software engineering?
  • Anywhere in the world, where would you open up a new Google office and how would you figure out compensation for all the employees at this new office?
  • What is the probability of breaking a stick into 3 pieces and forming a triangle?
Engineering Manager
  • You’re the captain of a pirate ship, and your crew gets to vote on how the gold is divided up. If fewer than half of the pirates agree with you, you die. How do you recommend apportioning the gold in such a way that you get a good share of the booty, but still survive?
AdWords Associate
  • How would you work with an advertiser who was not seeing the benefits of the AdWords relationship due to poor conversions?
  • How would you deal with an angry or frustrated advertisers on the phone?
Sources
摘要: 明眼人都看得出来,谷歌这是要借助摩托罗拉在手机上的大量专利来震慑某一些竞争对手,警告其不要轻举妄动。起到保护尚在成长当中的android系统的目的,谷歌做出这样的举动并不令人吃惊,吃惊的是摩托罗拉做出这样的决策,摩托目前在android市场上虽然不是最红火的,但也已经是挺过了最艰难的时刻了,正是收获的季节了。突然这么简单就放手了,确实很有魄力。摩托豪赌android系统,当然不希望其这么快被打败,要维护其成长空间的心态也是不言而喻的,当然,魄力后面都是利益。也许在几年之后,android度过最艰难的时刻之后,摩托罗拉会在某一天突然宣布:收购谷歌手机部门。。。。也许这是一个对谷歌和摩托罗拉是一个阅读全文
 
posted @ 2011-08-15 22:25 elite_lcf 阅读(16) 评论(0) 编辑
 
摘要: 5月31日,世界卫生组织下辖的国际癌症研究机构(IARC)宣布,在对关于使用手机与脑癌的科学文献做了历时一周的集中梳理之后,他们决定将手机使用中产生的射频电磁场划分为“可能致癌”级别。(报告在此)许多媒体报道指出,该报告将手机使用与铅和氯仿(的使用)同归于2B级(山寨吐槽1:悲催的级别啊有木有……)。但,铅的危害是由于它会导致儿童大脑发育障碍,而氯仿本身就是剧毒的,这些危害性都与癌症无关 。而在和谐战线这一方 , CTIA(美国移动通信行业协会) 则拿出咖啡和泡菜 两种同样归在2B级中,不过听起来不那么恐怖的东西来说明问题。(山寨吐槽2:太不给周立波面子了……)看来无论是想要撩起正面的还是负面阅读全文
 
posted @ 2011-06-19 00:20 elite_lcf 阅读(13) 评论(0) 编辑
 
摘要: typedef目录概述typedef用法小结代码简化促进跨平台开发C语言中typedef用法编辑本段概述 是一种在计算机编程语言中用来声明自定义数据类型,配合各种原有数据类型来达到简化编程的目的的类型定义关键字。编辑本段typedef用法小结 在C语言的情况下,与C++稍有出入。typedef在结构体定义,还有一些数组等地方都大量的用到。归纳一下: 来源一:Using typedef to Curb Miscreant Code Typedef 声明有助于创建平台无关类型,甚至能隐藏复杂和难以理解的语法。不管怎样,使用 typedef 能为代码带来意想不到的好处,通过本文你可以学习用 type阅读全文
 
posted @ 2011-05-14 11:19 elite_lcf 阅读(29) 评论(0) 编辑
 
摘要: 【日常小记】linux中强大且常用命令:find、grep转自:http://www.cnblogs.com/skynet/archive/2010/12/25/1916873.html在linux下面工作,有些命令能够大大提高效率。本文就向大家介绍find、grep命令,他哥俩可以算是必会的linux命令,我几乎每天都要用到他们。本文结构如下:find命令find命令的一般形式find命令的常用选项及实例find与xargsgrep命令grep命令的一般形式grep正则表达式元字符集(基本集)grep命令的常用选项及实例1、find命令find命令是一个无处不在命令,是linux中最有用的命阅读全文
 
posted @ 2010-12-27 02:14 elite_lcf 阅读(437) 评论(0) 编辑
 
摘要: Linux Socket编程(不限Linux)2010-12-12 21:58 by 吴秦, 1620 visits,网摘,收藏,编辑“一切皆Socket!”话虽些许夸张,但是事实也是,现在的网络编程几乎都是用的socket。——有感于实际编程和开源项目研究。我们深谙信息交流的价值,那网络中进程之间如何通信,如我们每天打开浏览器浏览网页时,浏览器的进程怎么与web服务器通信的?当你用QQ聊天时,QQ进程怎么与服务器或你好友所在的QQ进程通信?这些都得靠socket?那什么是socket?socket的类型有哪些?还有socket的基本函数,这些都是本文想介绍的。本文的主要内容如下:1、网络中进阅读全文
 
posted @ 2010-12-27 02:12 elite_lcf 阅读(1262) 评论(0) 编辑
 
摘要: 现在有事没事就喜欢写写代码的人越来越多了,对于成天盯着屏幕工作的开发人员来说,编程代码可能是每天见得最多的东西了。可是绝大部分人都一直使用编辑器默认的字体,其实,换一套适合自己的编程字体不仅能让代码看得更舒服,甚至还能提高工作效率的!如果你有想过换一种编程字体,却不知道哪里找合适的,那么看看异次元软件世界为您推荐的10款最适合编程的字体吧,这些字体能让你的代码瞬间“优雅”起来!换一种字体,换一番心情嘛。当然,除了编程之外,经常需要编辑英文文档的朋友同样适用……前言:下面字体的排序是作者的主观感受,每个人的喜好都不一样。建议您都试试,按照自己的喜好来选择。另外,还在使用 Windows XP 的阅读全文
 
posted @ 2010-12-26 10:21 elite_lcf 阅读(1113) 评论(0) 编辑
 
摘要: 某猎头收集了140多个Google的面试题,都张到他的Blog中了,主要是下面这些职位的,因为被墙,且无任何敏感信息,所以,我原文搬过来了。Product Marketing ManagerProduct ManagerSoftware EngineerSoftware Engineer in TestQuantitative Compensation AnalystEngineering Man...阅读全文
 
posted @ 2010-12-03 23:28 elite_lcf 阅读(1363) 评论(0) 编辑
 
摘要: 文/张巡  在说Hadoop之前,作为一个铁杆粉丝先粉一下Google。Google的伟大之处不仅在于它建立了一个强悍的搜索引擎,它还创造了几项革命性的技术:GFS,MapReduce,BigTable,即所谓的Google三驾马车。Google虽然没有公布这几项技术的实现代码,但它发表了详细的设计论文,这给业界带来了新鲜气息,很快就出现了类似于Google三驾马车的开源实现,Hadoop就是其中...阅读全文
 
posted @ 2010-12-01 19:54 elite_lcf 阅读(278) 评论(0) 编辑
 
摘要: 这个帖子原本是在C++奋斗乐园论坛讨论的,后来觉得有必要和更多朋友分享下,所以就在这里也贴出来了,希望大家一起补充。因为我个人学的是C/C++的,所以JAVA等程序语言的书籍我就不讨论了。这里讨论的主要是C/C++的经典书籍,另外还有计算机专业要学的一些重要课程领域的书。  C/C++:  《C程序设计语言》http://book.douban.com/subject/1139336/  《C P...阅读全文
 
posted @ 2010-12-01 19:53 elite_lcf 阅读(1647) 评论(0) 编辑
 
摘要: 用过linux下terminal的人对这样的命令提示符都不会感到陌生  user@hostname-laptop~$  这样的提示符本没什么问题,特别是多用户状态下,还能清楚地知道自己的用户名的主机。  但是,它有一个毛病,那就是把目录同时显示了出来,有时候目录过长的时候,占用了整行,让人很郁闷,比如  user@hostname-laptop/usr/local/share/man$  当然,在...阅读全文
 
posted @ 2010-11-29 19:28 elite_lcf 阅读(254) 评论(0) 编辑
 
摘要: 刚开始学习《UNIX网络编程》这本书,摸索了很久才知道怎么用源码。。写下来。。1.第一个例子用需要 daytime服务,UBUNTU默认没有开启这个服务。。要先开启。参考:http://ubuntuforums.org/showthread.php?t=650791说明:先执行sudo aptitude install xinetd,然后修改其配置文件,进入etc/xinetd.d,把daytim...阅读全文
 
posted @ 2010-11-29 18:31 elite_lcf 阅读(69) 评论(0) 编辑
 
摘要: “你现在用什么手机?”“诺基亚。呃,上一款是摩托罗拉。”  5年前,这是人们习惯的问答模式。不需说明,大家也明白,彼此询问和感兴趣的是手机的品牌。  “你现在用什么手机?”“Android。不过,我还想去买台iPhone4  现在,新一代的思考模式已经不再以手机的品牌为定向,而是更为看重手机的操作平台。  看上去,...阅读全文
 
posted @ 2010-11-29 11:19 elite_lcf 阅读(33) 评论(0) 编辑
 
摘要: UTF-8:Unicode TransformationFormat-8bit,允许含BOM,但通常不含BOM。是用以解决国际上字符的一种多字节编码,它对英文使用8位(即一个字节),中文使用24为(三个字节)来编码。UTF-8包含全世界所有国家需要用到的字符,是国际编码,通用性强。UTF-8编码的文字可以在各国支持UTF8字符集的浏览器上显示。如,如果是UTF8编码,则在外国人的英文IE上也能显示...阅读全文
 
posted @ 2010-11-28 19:03 elite_lcf 阅读(429) 评论(0) 编辑
 
摘要: 10个箱子,每个箱子10个苹果,其中一个箱子的苹果是9两/个,其他的都是1斤/个。 要求利用一个秤,只秤一次,找出那个装9两/个的箱子。阅读全文
 
posted @ 2010-11-18 23:45 elite_lcf 阅读(45) 评论(0) 编辑
 
摘要: 主办的中国首届微博开发者大会在北京举行,这是国内微博行业的首场技术盛宴。作为国内微博市场的绝对领军者,新浪微博将在此次大会上公布一系列针对开发者的扶持政策,以期与第三方开发者联手推动微博行业的整体发展。图为微博平台首席架构师杨卫华演讲。  以下为演讲实录:  大家下午好,在座的大部分都是技术开发者,技术开发者往往对微博这个产品非常关心。最晚的一次,是12点多收到一个邮件说想了解一下微博底层是怎么构...阅读全文
 
posted @ 2010-11-17 10:21 elite_lcf 阅读(234) 评论(0) 编辑
 
摘要: 1、【杂志名称】 计算机应用研究 【杂志文章包含专业】建模,仿真,网络,人工智能,比较杂。 【投稿联系方式】http://www.arocmag.com/注册在线投稿审稿 【投稿费用】250元/页 【杂志级别】国家一级期刊,全国中文核心期刊 【稿酬回报】无 【投稿感受】录用率始终保持在60%以上,不包括增刊,想上增刊,交钱就行(250元/页)。无审稿费,1~2月就知道结果了!2、【杂志名称】火力与...阅读全文
 
posted @ 2010-11-12 00:41 elite_lcf 阅读(23) 评论(0) 编辑
 
摘要: 经常面对电脑的人,难免会受到这个高科技产品的危害,辐射,久坐电脑前带来的肥胖,眼睛疲劳等电脑带来的一系列问题无法避免,那么怎样将伤害降到最小呢,小编来支招吧。  防辐射  要预防电磁辐射的伤害,应增加枸杞子食品、花粉食品的摄入。枸杞子补肝、明目,具有保护视网膜免受光损伤、清除自由基和抗X射线辐射的作用。花粉含有大量的核酸、氨基酸、维生素、烟酸、叶酸等生物营养成分。花粉中的氨基酸能提高受辐射动物外周...阅读全文
 
posted @ 2010-11-11 18:38 elite_lcf 阅读(20) 评论(0) 编辑
 
摘要: 马云  今年9月10日,马云在他的福地杭州,与数百人一起,庆祝了他的46岁生日。到贺者包括加州州长阿诺德·施瓦辛格、美国驻华大使约翰·韩志曼等,甚至他的竞争对手——eBay总裁兼CEO约翰·多纳霍也出席并致辞。在300多媒体记者的闪光灯下,马云将施瓦辛格送上的贺礼——黑色皮夹克和黑色墨镜穿戴上身,曾经自嘲因为整天奇思怪想...阅读全文
 
posted @ 2010-11-10 18:53 elite_lcf 阅读(76) 评论(0) 编辑
 
摘要: 公交车上,一人问:“大S是S.H.E里的阿sa吗?”另一人答:“大哥你是火星人啊,大S是twins里的selina,刚被烧伤的那个,汪小菲还是有情义的……”  由于缺乏技术背景,很多时候,“不明真相的群众”在热议3Q大战的时候,就像这两哥们在八卦“大S是谁”。当然,其中不乏有意浑...阅读全文
 
posted @ 2010-11-10 18:47 elite_lcf 阅读(139) 评论(0) 编辑
 
摘要: 堵车在各个城市已经是家常便饭,特别是在北京,不求跑得快只求不堵车已经成为有车人士们每天的渴望之一。在一个城市密密麻麻的水泥森林中,最熟悉地形和路线的就是出租车司机们,这些师傅知道怎样可以绕过堵塞路段用最快的路线达到目的地,现在微软也瞄上了这些师傅们的特技。  微软亚洲研究院希望借助出租车司机们的集体智慧为Bing地图提供更好的行车路线规划,目前已经已经给北京超过30000辆出租车安装了GPS设备,...阅读全文
 
posted @ 2010-11-10 14:26 elite_lcf 阅读(18) 评论(0) 编辑
 
摘要: google,chrome广告阅读全文
 
posted @ 2010-11-09 23:27 elite_lcf 阅读(17) 评论(0) 编辑
 
摘要: 亲爱的QQ用户:当您看到这封信的时候,我们刚刚作出了一个非常艰难的决定。在360公司停止对QQ进行外挂侵犯和恶意诋毁之前,我们决定将在装有360软件的电脑上停止运行QQ软件。我们深知这样会给您造成一定的不便,我们诚恳的向您致歉。同时也把作出这一决定地原因写在下面,盼望得到您的理解和支持。一、保障您的QQ帐户安全近期360强制推广并胁迫用户安装非法外挂“扣扣保镖”。该软件劫持...阅读全文
 
posted @ 2010-11-03 18:40 elite_lcf 阅读(89) 评论(1) 编辑
 
摘要: 天河一号超级计算机跃居世界第一 使用国产CPU2010年10月29日 08:31中广网【大中小】【打印】共有评论542条“天河一号”超级计算机系统采用了“飞腾-1000”高性能多核微处理器。中广军事记者孙利 摄中广网北京10月28日消息(记者孙利、王握文)中国高性能计算机TOP100组织今天发布数据,“天河一号”超级计算机二期...阅读全文
 
posted @ 2010-10-31 10:46 elite_lcf 阅读(55) 评论(0) 编辑
 
摘要: 利用c.vim插件,你可以实现添加文件头添加注释插入一些代码片段语法检查读函数文档注释代码块这一插件的作者是Fritz Mehner,目标就是打造程序员流畅的编辑环境。这一插件还能完成:Statement oriented editing of C / C++ programsSpeed up writing new code considerably.Write code and comment...阅读全文
 
posted @ 2010-10-27 23:37 elite_lcf 阅读(1531) 评论(0) 编辑
 
摘要: 放弃IDE,用VIM进行c/c++程序开发老廖曾经在PHPER杂志上发表过一篇文章叫做用VIM做PHP开发环境,在里面详细介绍了用VIM做php开发需要做的准备,这篇文章就结合一些资料和我自己的一些经验来介绍下用VIM做C/C++开发需要做的事情,相对来说要比做php开发方便些。前提条件是当然是你已经下载了VIM,如果没有的话请先到官方网站下载最新版本,地址是:http://www.vim.org...阅读全文
 
posted @ 2010-10-27 23:36 elite_lcf 阅读(647) 评论(0) 编辑
 
摘要: 如何在linux下面配置Vim+c.vim+Ctags+taglist收藏最近由于公司编程的需要,我发现键盘流的很多好处,因为由于没有过于繁琐的GUI 的限制,速度也就可以提升,更何况在linux下工作,把自己打造成一个键盘流还是有很多好处的。1、 准备工作,首先可以查看一下在linux机器上的vim的版本,建议大家用新的Vim 7.2版本,据说这个版本还是比较稳定的。如果没有安装vim7.2可以...阅读全文
 
posted @ 2010-10-27 23:34 elite_lcf 阅读(484) 评论(0) 编辑
 
摘要: 阿里巴巴10月20日在北京邮电大学举办了首场校园招聘宣讲会,阿里巴巴B2B业务CEO卫哲在演讲中给出了四个不加盟阿里巴巴的理由,包括工资非最高、要放弃北京去杭州、马云和他都不是技术型CEO以及不想长年累月加班。  卫哲还透露,阿里巴巴目前在北京只有600名员工,正计划在北京盖一座办公楼,但仅供办公室用,阿里巴巴不会投资任何房地产项目。  以下为卫哲给出的四个不加入阿里巴巴理由部分的演讲实录:  今...阅读全文
 
posted @ 2010-10-26 22:12 elite_lcf 阅读(91) 评论(0) 编辑
 
摘要: http://forums.codeblocks.org/index.php?topic=3055.msg%msg_id%codeblocks中默认的终端事xterm,但是xterm的中文支持不是很好,所以当你显示中文的时候,他往往直接显示空白。将xterm换为gnome-terminal是一个很好的选择,gnome-terminal下中文的显示要比xterm好很多。将设置里面的环境项中xterm...阅读全文
 
posted @ 2010-10-25 21:23 elite_lcf 阅读(444) 评论(0) 编辑
 
摘要: 总策划/吴晓宇执行/本刊编辑部文/吴晓宇徐上峰王盼林涛丁乙乙秦倩倩周元英当经济危机的阴霾逐渐飘散,IT业渐渐恢复往日生机,这个10月,我们步入创刊以来的第10个秋天。10年间,产业界风云变幻,盛衰更迭,我们最初的信念和风骨却从未动摇,解读并推动信息时代的商业变革仍然是我们不变的宗旨;真诚、独立、自律仍旧是我们始终如一的操守;如履薄冰、不断创新,依然是我们持之以恒的从业心态。我们诞生于数字化时代,成...阅读全文
 
posted @ 2010-10-25 19:03 elite_lcf 阅读(67) 评论(1) 编辑
 
摘要: 1. 给定a、b两个文件,各存放50亿个url,每个url各占64字节,内存限制是4G,让你找出a、b文件共同的url?方案1:可以估计每个文件安的大小为50G×64=320G,远远大于内存限制的4G。所以不可能将其完全加载到内存中处理。考虑采取分而治之的方法。s 遍历文件a,对每个url求取,然后根据所取得的值将url分别存储到1000个小文件(记为)中。这样每个小文件的大约为300M...阅读全文
 
posted @ 2010-10-24 19:51 elite_lcf 阅读(1605) 评论(0) 编辑
 
摘要: 格式化输出http://www.neu.edu.cn/cxsj/pointchart/c4/Page5.htmlTAG: 格式输入,标准输入输出TEXT:printf函数称为格式化输出函数,其功能是按用户指定的格式(控制字符串规定的格式),将指定的数据项输出到标准的输出设备(一般为显示器)上。REF:.TXTprintf函数TAG: printf函数,标准输入输出TEXT:printf函数是一个标...阅读全文
 
posted @ 2010-10-23 12:57 elite_lcf 阅读(276) 评论(0) 编辑
 
摘要: 也许你听说过去微软面试很难,可能你没有听过一个人同时出现在微软的各个部门里面进行面试。而我就是这样的一位。在这里我很感谢中软国际,也特别感谢上海微创为我提供这么多次机会,让我在面试中不断总结,不断提高。以下是我整理的一些面试题,供大家参考:大战微软面试2009年3月23号全球微软技术支持中心1、老外面试主要问的问题是:1)、你是否有项目经验,2)、你做过什么项目?3)、简单的介绍一下你的项目4)、...阅读全文
 
posted @ 2010-10-23 12:57 elite_lcf 阅读(118) 评论(0) 编辑
 
摘要: 关于C++中的const关键字的用法非常灵活,而使用const将大大改善程序的健壮性,参考了康建东兄的const使用详解一文,对其中进行了一些补充,写下了本文。1. const常量,如const int max = 100;优点:const常量有数据类型,而宏常量没有数据类型。编译器可以对前者进行类型安全检查,而对后者只进行字符替换,没有类型安全检查,并且在字符替换时可能会产生意料不到的错误(边际...阅读全文
 
posted @ 2010-10-23 12:56 elite_lcf 阅读(307) 评论(0) 编辑
 
摘要: C语言中printf格式化输出函数 收藏用 法:  int printf(const char *format,[argument]);  format 参数输出的格式,定义格式为:  %[flags][width][.perc] [F|N|h|l]type  规定数据输出方式,具体如下:  1.type 含义如下:  d 有符号10进制整数  i 有符号10进制整数  o 有符号8进制整数  u...阅读全文
 
posted @ 2010-10-23 12:56 elite_lcf 阅读(733) 评论(0) 编辑
 
摘要: C语言 sizeof函数详解 收藏sizeof,一个其貌不扬的家伙,引无数菜鸟竟折腰,小虾我当初也没少犯迷糊,秉着“辛苦我一个,幸福千万人”的伟大思想,我决定将其尽可能详细的总结一下。但当我总结的时候才发现,这个问题既可以简单,又可以复杂,所以本文有的地方并不适合初学者,甚至都没有必要大作文章。但如果你想“知其然,更知其所以然”的话,那么这篇文章对你...阅读全文
 
posted @ 2010-10-23 12:55 elite_lcf 阅读(75) 评论(0) 编辑
 
摘要: 概述  在很多情况下,尤其是读别人所写代码的时候,对 C语言声明的理解能力变得非常重要,而C语言本身的凝练简约也使得C语言的声明常常会令人感到非常困惑,因此,在这里我用一篇的内容来集中阐述一下这个问题。  问题:声明与函数  有一段程序存储在起始地址为 0的一段内存上,如果我们想要调用这段程序,请问该如何去做?  答案  答案是 (*(void (*)( ) )0)( )。看起来确实令人头大,那好...阅读全文
 
posted @ 2010-10-23 12:37 elite_lcf 阅读(82) 评论(0) 编辑
 
摘要: 在互联网相当普及的今天,在互联网上聊天对很多“网虫”来说已经是家常便饭了。聊天室程序可以说是网上最简单的多点通信程序。聊天室的实现方法有很多,但都是利用所谓的“多用户空间”来对信息进行交换,具有典型的多路I/O的架构。一个简单的聊天室, 从程序员的观点来看就是在多个I/O端点之间实现多对多的通信。其架构如图一所示。这样的实现在用户的眼里就是聊天室内任...阅读全文
 
posted @ 2010-10-23 12:34 elite_lcf 阅读(226) 评论(0) 编辑
 
摘要: 3、字符串复制strcpy,strncpy,wcscpy,wcsncpy:将字符串src(或其前n个字符)复制到dest中,覆盖dest的内容。实现中先检查指针是否越界,计算指针dest到src的偏移,然后开始做复制操作,复制到dest的开始位置处,以覆盖dest的内容。对strncpy,也采用了每4个字符作为一组来进行复制的方法,以加快复制速度。view plaincopy to clipboa...阅读全文
 
posted @ 2010-10-23 12:13 elite_lcf 阅读(190) 评论(0) 编辑
 
摘要: 树的直径是指树的最长简单路。求法: 两遍BFS :先任选一个起点BFS找到最长路的终点,再从终点进行BFS,则第二次BFS找到的最长路即为树的直径; 原理: 设起点为u,第一次BFS找到的终点v一定是树的直径的一个端点 证明: 1) 如果u 是直径上的点,则v显然是直径的终点(因为如果v不是的话,则必定存在另一个点w使得u到w的距离更长,则于BFS找到了v矛盾) 2) 如果u不是直径上的点,则u到...阅读全文
 
posted @ 2010-10-23 09:27 elite_lcf 阅读(351) 评论(0) 编辑
 
摘要: 位计算(Bit Count)最近在重写黑白棋的底层数据结构,用位棋盘作为棋盘格式。用位棋盘计算移动力是相当快的,每次在一个方向上产生所有合法的着法,经8次(8个方向)就可以得到所有合法的着法,并将long数据中相应位置1,最后计算的个数。计算一个整数中多少位被置为1,是一个比较常见的问题,http://infolab.stanford.edu/~manku/bitcount/bitcount.ht...阅读全文
 
posted @ 2010-10-22 22:26 elite_lcf 阅读(313) 评论(0) 编辑
 
 
摘要: 题目转自:http://blog.163.com/ecy_fu/blog/static/444512620098228849190/二笔只有三道题,分值分别为30, 30, 40,题分别如下:1、实现strtol函数,其原型如为int strtol(const char *num_str, char **endptr, int base),num_str存放待转换的字符串,可以是负数也可以是正数;...阅读全文
 
posted @ 2010-10-15 18:04 elite_lcf 阅读(86) 评论(0) 编辑
 
摘要: 如上图所示,本文的主要目的是生成一个这样按红线顺序从1,2,3,4,5,6,...的不断变换螺旋方向的螺旋矩阵。此种矩阵是前几天华为面试的时候提出来的,当时只是给出了一个解决方法,并没有写实现代码,今天有时间整理一下把代码写出来供大家分享。算法思路:根据每一个奇数首行和偶数首列为平方数的特点,分别以这点位依据去填充数据。程序输出:C#代码如下:代码Code highlighting produce...阅读全文
 
posted @ 2010-09-16 19:32 elite_lcf 阅读(644) 评论(3) 编辑
 
摘要: 1 基本解释  extern可以置于变量或者函数前,以标示变量或者函数的定义在别的文件中,提示编译器遇到此变量和函数时在其他模块中寻找其定义。  另外,extern也可用来进行链接指定。2 问题:extern 变量  在一个源文件里定义了一个数组:char a[6];  在另外一个文件里用下列语句进行了声明:extern char *a;  请问,这样可以吗?  答案与分析:  1)、不可以,程序...阅读全文
 
posted @ 2010-09-10 14:33 elite_lcf 阅读(28) 评论(0) 编辑
 
摘要: extern的用法,头文件,全局变量等概念阅读全文
 
posted @ 2010-09-10 14:28 elite_lcf 阅读(82) 评论(0) 编辑
 
摘要: 一个清华学生留学香港后对人生的思考----名校就是名校,可见精英阶层的存在是不争的,难得看到那么清明的文字(转) 来源: 杨永富的日志写的是真的很好的,今天看的两篇文字都特别有感觉,一个励志,一个醒身。。。红字是此文原来带着的,蓝色的字是看过了这些话跟自己产生了共鸣所以标注上来的~~~~~这也是为什么不分享而是自私的保留的一个原因~~~~~~也算是一篇蓝色的日志吧~~98年本科毕业,又顺利地被保研...阅读全文
 
posted @ 2010-09-02 13:41 elite_lcf 阅读(73) 评论(0) 编辑
 
摘要: MSDN Visual Studio 2010 中文版 (含下载地址 和KEY)文章分类:.net编程本人 已验证中文U版与官方公布的一致,其它版本请大家自行验证SHA1: 44B73423A7BBCE38D06BA55ECD821946630BEA4D软件版本: Visual Studio 2010-------------------------------------------------...阅读全文
 
posted @ 2010-08-20 11:54 elite_lcf 阅读(21) 评论(0) 编辑
 
摘要: How to install NCTUns in Debian/UbuntuContenido[ocultar]1Introduction2Dependencies3Download NCTUns4Modify NCTUns5Build NCTUns6Run the NCTUns GUI7Run the NCTUns dispatcher/coordinator7.1Create the NCTU...阅读全文
 
posted @ 2010-06-10 22:58 elite_lcf 阅读(365) 评论(0) 编辑
 
摘要: 在使用Ubuntu之前,相信很多人都有过使用Windows系统的经历。如果你备份过Windows系统,那么你一定记忆犹新:首先需要找到一个备份工具(通常都是私有软件),然后重启电脑进入备份工具提供的软件环境,在这里备份或者恢复Windows系统。Norton Ghost是备份Windows系统时经常使用的备份工具。 在备份Windows系统的时候你可能想过,我能不能把整个C盘都放到一个ZIP文件里...阅读全文
 
posted @ 2010-06-10 10:27 elite_lcf 阅读(214) 评论(0) 编辑
 
摘要: 七款优秀的计算器Extcalc:多功能科学图形计算器;http://extcalc-linux.sourceforge.net/SpeedCrunch:强大的高精度桌面计算器;http://speedcrunch.org/Genius Mathematics Tool:数学教育工具;http://www.jirka.org/genius.htmlQalculate!:功能强大、易于使用的计算器;h...阅读全文
 
posted @ 2010-05-31 01:37 elite_lcf 阅读(34) 评论(0) 编辑
 
摘要: 1.先看下面的例子:struct A{ char c1; int i; short s; int j;}a;struct B{ int i; int j; short s; char c1;}b;结构A没有遵守字节对齐原则(为了区分,我将它叫做对齐声明原则),结构B遵守了。我们来看看在x86上会出现什么结果。先打印出a和b的各个成员的地址。会看到a中,各个成员间的间距是4个字节。b中,i和j,j和...阅读全文
 
posted @ 2010-05-24 14:53 elite_lcf 阅读(987) 评论(0) 编辑
 
摘要: 由于程序运行时占用的内存过大,所以想办法给程序瘦身。在调试中发现结构体占用的size竟然和预想的不一样,原来……看看下面讲的吧,肯定会不枉此看哦!1,比如:struct{ short a1; short a2; short a3;}A;struct{ long a1; short a2;}B;sizeof(A)=6, sizeof(B)=8,为什么?注:sizeof(sho...阅读全文
 
posted @ 2010-05-24 14:52 elite_lcf 阅读(298) 评论(0) 编辑
 
摘要: 1月9日不用浩方互联网打魔兽争霸全攻略昨天和hewei晚上做了全面测试,总结出如下方法。魔兽建立连接分析1 udp获得游戏列表(A是主,B是客户机)B进入游戏,进入局域网,会向局域网发出udp广播,udp目标端口是6112,A收到这个广播后返回一个udp包给B,B才会在魔兽的游戏列表里看到A建的游戏。2看到A建的游戏后,B双击进入游戏会建立一个到A的tcp连接,端口也是6112 。游戏方案1利用使...阅读全文
 
posted @ 2010-05-13 00:03 elite_lcf 阅读(967) 评论(0) 编辑
 
摘要: 浩方对战平台是一个基于VPN技术的、将互联网上的两个或多个用户模拟成在同一局域网的通用性联网技术,其本质是提供用户间的数据交换,当你用浩方游戏客户端登陆进入相应的房间后,服务器端会自动给你分配一个“虚拟IP地址",不论你的上网接入方式是拨号/ADSL/LAN/CABLE MODEM,在同一个游戏房间里,你就会有一个虚拟IP,这个IP只是为了玩家之间联网游戏用的。浩方游戏平台通过把tc...阅读全文
 
posted @ 2010-05-12 23:17 elite_lcf 阅读(348) 评论(0) 编辑
 
摘要: 飞信的协议分析转自:http://hi.baidu.com/nathan2007/blog/category/%B7%C9%D0%C5%D0%AD%D2%E9%B7%D6%CE%F6作者:nathan以下分析均基于飞信的这一版本:Fetion 2006 beta 版本 2.1.0.0。被迫开始用飞信(Fetion),痛苦啊,这玩意儿开发了几年(飞信博客上一家伙说参加飞信项目两年了),而且用的是.N...阅读全文
 
posted @ 2010-04-07 17:02 elite_lcf 阅读(261) 评论(0) 编辑
 
摘要: 事实上dll注入很简单,无非就是调用virtualAllocEx,WriteProcessMemory,OpenProcess,CreateRemoteThread等API函数,因为我是学c#的,所以也想看一下c#这方面的文章,但在网上找了半天,没有找到一篇,也许是c#刚兴起的缘故,学c#的并不多,没办法,只好自己移植一下,因为凡是用到API函数,所有的编程的语言都是相同的,这就为我们的移植带来了...阅读全文
 
posted @ 2010-04-02 12:38 elite_lcf 阅读(96) 评论(0) 编辑
 
摘要: 前记:  前几天在图书馆自习的时候,看到一位仁兄非常不幸的在上厕所的时候,被人卷走放在图书馆自习室里的笔记本,mp3等物。哀其不幸,写此软件,以避免之后此类事件发生在我的爱机身上。思路:  大部分小偷在图书馆等公共场所偷窃笔记本时都是直接合上翻盖,拔了电源就走;而笔记本都是自带电池工作的,这时笔记本仍然处于系统启动状态,足可以自己做出“反应”,以抗拒被人胁迫带走的命运!就是...阅读全文
 
posted @ 2010-04-02 12:18 elite_lcf 阅读(3228) 评论(52) 编辑
 
摘要: b阅读全文
 
posted @ 2010-04-02 10:46 elite_lcf 阅读(166) 评论(0) 编辑
 
摘要: 原问题是这样的:玩某游戏中,一个Boss死亡之后会随机掉落物品,一共有四种物品可能会掉落,Boss每次死亡之后都会掉落一种物品,四种物品掉落的概率完全相同。现在需要收集其该Boss掉落的四件物品,完成某项任务。问:平均要杀死该Boss多少次才能凑满全部4个物品。该问题实际上就是求boss掉落全部四个物品的数学期望,数学期望为值和概率之积的全和。即s=4*p(4) + 5*p(5) + &helli...阅读全文
 
posted @ 2010-03-31 00:55 elite_lcf 阅读(2068) 评论(12) 编辑
 
摘要: 微软IE8、苹果Safari及火狐(Firefox)等三大浏览器相继被攻破(腾讯科技配图)腾讯科技讯(编译/中涛)北京时间3月25日消息,据国外媒体报道,在本周三于加拿大温哥华市举行的2010年Pwn2Own全球黑客大赛上,苹果iPhone智能手机、苹果Safari、微软IE8及火狐(Firefox)等浏览器相继被参赛者攻破,但谷歌Chrome浏览器当天仍“固若金汤”。20...阅读全文
 
posted @ 2010-03-25 22:48 elite_lcf 阅读(152) 评论(2) 编辑
 
摘要: 家好,突然想写些东西给准备读博士的朋友们看看!现在硕士多了,很多人想读博士了,但很多人可能根本就不知道博士是怎么一回事就盲目随从。我觉得首先你得知道以下得几点你再考虑读不读博士。1认识自己。这个好像很可笑,但是很多人就是迷迷糊糊,根本就不能很好地定位自己。曾经一个朋友对我这样说,“我在一个地方连续待上2个小时就受不了了,想外出活动活动。我从南京坐车到上海,到后再坐车到北京,办完事后立即...阅读全文
 
posted @ 2010-03-23 22:13 elite_lcf 阅读(726) 评论(0) 编辑
 
摘要: 刚看到google新闻,3月18日日本科学理事会发布了未来10年,日本的大科学计划,计划涵盖了航天,生物,医学,量子物理,天文物理,信息科学等多个学科。从其下送选的100个项目中提出48项计划,作为未来十年日本的重点科学发展方向。把他的计划纲目下下来了,又去google了一番想找到计划的详细细则,没找到,只把此文件先传上来。有心人共阅。日本大科学计划阅读全文
 
posted @ 2010-03-19 13:23 elite_lcf 阅读(63) 评论(0) 编辑
 
摘要: 一道不怎么容易的算法题解决办法http://www.cnblogs.com/sevendays/archive/2010/03/18/1689291.html读上文,有感而作给出一个递归算法;1、将一个n维数组初始化,第0位填1,第1位填2.。。。。。 第n-1位填n;2、将数组看为两部分,一个是已排好的,剩下是待排的,分别用两个指针指向;3、将第一个字符,依次与后n-1个字符交换值,每次交换得到...阅读全文
 
posted @ 2010-03-19 01:00 elite_lcf 阅读(2442) 评论(10) 编辑
 
摘要: 下载从[1]下载DVD压缩包,用最新版的7-zip[2]将texlive2009.iso.xz解压为texlive2009.iso。安装用虚拟光驱软件加载texlive2009.iso“开始”->运行"cmd",切换到texlive2009根目录运行./install-tl.bat -gui,进入图形界面配置安装。安装中文字体[6]中有adobe中文字体。一般来说不用...阅读全文
 
posted @ 2010-03-18 01:28 elite_lcf 阅读(136) 评论(0) 编辑
 
摘要: 格式项的语法是 {index[,alignment][:formatString]},它指定了一个强制索引、格式化文本的可选长度和对齐方式,以及格式说明符字符的可选字符串,其中格式说明符字符用于控制如何设置相应对象的值的格式。格式项的组成部分包括:index 从零开始的整数,指示对象列表中要格式化的元素。如果由 index 指定的对象是 空引用(在 Visual Basic 中为 Nothing)...阅读全文
 
posted @ 2010-03-15 12:11 elite_lcf 阅读(196) 评论(0) 编辑
 
摘要: 输出螺旋型数字阅读全文
 
posted @ 2010-03-11 01:48 elite_lcf 阅读(2114) 评论(22) 编辑
 
摘要: #include<stdio.h>int __=*"CIW_BLUE">>6;int main(int _){ _<10?__<=_?printf("%d*%d=%d ",_,__,_*__),__++,main(_):putchar(10),__=1,main(++_):main(++_);}阅读全文
 
posted @ 2010-03-10 18:06 elite_lcf 阅读(76) 评论(0) 编辑
 
摘要: 蒙特霍尔问题:蒙提霍尔问题是一档由霍尔(Hall)主持的游戏节目:让我们来做交易(Let's Make a Deal)中,竞争者面临生死抉择。这个问题是1990年9月9日由马里兰州哥伦比亚的克雷格·惠特克(Craig Whitaker)提出的。“亲爱的玛丽莲,”惠特克写道。“如果你在这个游戏节目中,你面临三道门的选择,一扇门后面是一辆车,其它两扇门后面...阅读全文
 
posted @ 2009-11-17 01:06 elite_lcf 阅读(1499) 评论(17) 编辑
 
摘要: 一个9位数,如123456789,其前n位,可以被n整除。1/1=0;12/2=6;123/3=41;1234/4=....代码如下:代码:Code数据共有2492个阅读全文
 
posted @ 2009-11-16 19:25 elite_lcf 阅读(692) 评论(6) 编辑
 
摘要: 系统:vista软件:vs 2008我新建项目时,总会弹出如下提示:更多详细信息里面是园子里谁知道何解?阅读全文
 
posted @ 2009-10-30 19:24 elite_lcf 阅读(767) 评论(5) 编辑
 
摘要: 在c#中支持在类里面嵌套其他类,这意味着,在一个类里面定义另外一个类,在一个类里面声明另一个类都是可以的。 这就涉及到,如果我们把嵌套到其他类中的类(都为引用类型)作为函数参数传入,那么函数执行之后对原引用对象会不会有影响呢? 即定义这样的类 class classA { int i; //… classB B; } class test { public static void ma...阅读全文
 
posted @ 2009-10-14 00:14 elite_lcf 阅读(31) 评论(0) 编辑
 
摘要: 有时,代码要求非托管资源,如文件句柄、COM 包装或 SQL 连接。在使用一个或多个此类资源完成了代码后,Using块确保这些资源的释放。这样,其他代码就可以使用它们。 托管资源由 .NET Framework 垃圾回收器 (GC) 释放,您不需要进行任何额外的编码。您也不需要用于托管资源的Using块。 Using块有三个部分:获取、使用和释放。 获取表示创建变量并将其初始化,以便引用系统资源。...阅读全文
 
posted @ 2009-08-27 11:56 elite_lcf 阅读(365) 评论(0) 编辑
 
摘要: 数字转中文表示阅读全文
 
posted @ 2009-08-25 20:38 elite_lcf 阅读(250) 评论(2) 编辑
 
摘要: 文曲星,猜数游戏阅读全文
 
posted @ 2009-08-07 13:09 elite_lcf 阅读(50) 评论(0) 编辑
 
摘要: 本人建了一个SharpPCap讨论群,欢迎大家加入讨论C#下网络编程群号:60562113阅读全文
 
posted @ 2009-07-31 10:30 elite_lcf 阅读(141) 评论(0) 编辑
 
摘要: 想搞恶作剧的请看过来,,运行本源代码之后,你的电脑屏幕上会出现难以想象的效果,至于什么效果请自己尝试,呵呵,谢绝老爷机尝试,否则一切后果概不负责。;欢迎各位吃螃蟹的附上效果图.....建议:1、交c/c++作业的时候,把这个编译成dll,运行真正的程序前调用一下;(请估摸着老师的脾气来,让老师把电脑砸了就不好了)2、寝室的朋友啊,班上的同学啊,每个人电脑上给他安上一个,没事的时候,嗯,忽悠一下他的...阅读全文
 
posted @ 2009-07-31 10:01 elite_lcf 阅读(461) 评论(5) 编辑
 
摘要: /Files/hanyulcf/WinHanio.rar好久前写的一个程序了,刚开始的时候学c也好其他也好,都是用的控制台版的汉诺塔,一直没有写过图形界面的汉诺塔程序,刚接触c#的时候,就乱七八糟的谢了一堆代码实现汉诺塔的程序,用的button空间模拟塔层。本来要添加一个手动解的模块,后来要把button空间严格固定位置实在是很麻烦,就直接这样写了,有心人可以添加上去。代码全部无偿开放,哈哈界面如...阅读全文
 
posted @ 2009-07-30 12:52 elite_lcf 阅读(984) 评论(2) 编辑
 
摘要: 是看了你必须知道的.net知道了这个网站,申请博客通过,在这里留下自己学习的点滴成果吧。。阅读全文
 
posted @ 2009-07-29 15:37 elite_lcf 阅读(16) 评论(0) 编辑
 
 
原文地址:https://www.cnblogs.com/Leo_wl/p/2298417.html