﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-漫步者-文章分类-笔试面试题</title><link>http://www.cppblog.com/Walker/category/15676.html</link><description>先学会转文章，在仔细读文章，最后自己写点东西........</description><language>zh-cn</language><lastBuildDate>Sat, 21 May 2011 19:14:35 GMT</lastBuildDate><pubDate>Sat, 21 May 2011 19:14:35 GMT</pubDate><ttl>60</ttl><item><title>应聘时最漂亮的回答!</title><link>http://www.cppblog.com/Walker/articles/146843.html</link><dc:creator>漫步者×&amp;……%￥</dc:creator><author>漫步者×&amp;……%￥</author><pubDate>Fri, 20 May 2011 23:40:00 GMT</pubDate><guid>http://www.cppblog.com/Walker/articles/146843.html</guid><wfw:comment>http://www.cppblog.com/Walker/comments/146843.html</wfw:comment><comments>http://www.cppblog.com/Walker/articles/146843.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Walker/comments/commentRss/146843.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Walker/services/trackbacks/146843.html</trackback:ping><description><![CDATA[<p>1、请你自我介绍一下自己好吗？<br />回答提示：一般人回答这个问题过于平常，只说姓名、年龄、爱好、工作经验，这些在简历上都有。其实，企业最希望知道的是求职者能否胜任工作，包括：最强的技能、最深入研究的知识领域、个性中最积极的部分、做过的最成功的事，主要的成就等，这些都可以和学习无关，也可以和学习有关，但要突出积极的个性和做事的能力，说得合情合理企业才会相信。企业很重视一个人的礼貌，求职者要尊重考官，在回答每个问题之后都说一句&#8220;谢谢&#8221;，企业喜欢有礼貌的求职者。<br />2、你觉得你个性上最大的优点是什么？<br />回答提示：沉着冷静、条理清楚、立场坚定、顽强向上、乐于助人和关心他人、适应能力和幽默感、乐观和友爱。我在北大青鸟经过一到两年的培训及项目实战，加上实习工作，使我适合这份工作。<br />3、说说你最大的缺点？<br />回答提示：这个问题企业问的概率很大，通常不希望听到直接回答的缺点是什么等，如果求职者说自己小心眼、爱忌妒人、非常懒、脾气大、工作效率低，企业肯定不会录用你。绝对不要自作聪明地回答&#8220;我最大的缺点是过于追求完美&#8221;，有的人以为这样回答会显得自己比较出色，但事实上，他已经岌岌可危了。企业喜欢求职者从自己的优点说起，中间加一些小缺点，最后再把问题转回到优点上，突出优点的部分，企业喜欢聪明的求职者。<br />4、你对薪资的要求？<br />回答提示：如果你对薪酬的要求太低，那显然贬低自己的能力；如果你对薪酬的要求太高，那又会显得你分量过重，公司受用不起。一些雇主通常都事先对求聘的职位定下开支预算，因而他们第一次提出的价钱往往是他们所能给予的最高价钱，他们问你只不过想证实一下这笔钱是否足以引起你对该工作的兴趣。<br />回答样本一：我对工资没有硬性要求，我相信贵公司在处理我的问题上会友善合理。我注重的是找对工作机会，所以只要条件公平，我则不会计较太多。<br />回答样本二：我受过系统的软件编程的训练，不需要进行大量的培训，而且我本人也对编程特别感兴趣。因此，我希望公司能根据我的情况和市场标准的水平，给我合理的薪水。<br />回答样本三：如果你必须自己说出具体数目，请不要说一个宽泛的范围，那样你将只能得到最低限度的数字。最好给出一个具体的数字，这样表明你已经对当今的人才市场作了调查，知道像自己这样学历的雇员有什么样的价值。<br />5、你对加班的看法？<br />回答提示：实际上好多公司问这个问题，并不证明一定要加班，只是想测试你是否愿意为公司奉献。<br />回答样本：如果工作需要我会义不容辞加班，我现在单身，没有任何家庭负担，可以全身心的投入工作。但同时我也会提高工作效率，减少不必要的加班。<br />6、如果通过这次面试我们录用了你，但工作一段时间却发现你根本不适合这个职位，你怎么办？<br />回答提示：一段时间发现工作不适合我，有两种情况：&#9312;如果你确实热爱这个职业，那你就要不断学习，虚心向领导和同事学习业务知识和处事经验，了解这个职业的精神内涵和职业要求，力争减少差距；&#9313;你觉得这个职业可有可无，那还是趁早换个职业，去发现适合你的，你热爱的职业，那样你的发展前途也会大点，对单位和个人都有好处。<br />7、谈谈你对跳槽的看法？<br />回答提示：&#9312;正常的&#8220;跳槽&#8221;能促进人才合理流动，应该支持。&#9313;频繁的跳槽对单位和个人双方都不利，应该反对。<br />8、工作中难以和同事、上司相处，你该怎么办？<br />回答提示：&#9312;我会服从领导的指挥，配合同事的工作。&#9313;我会从自身找原因，仔细分析是不是自己工作做得不好让领导不满意，同事看不惯。还要看看是不是为人处世方面做得不好，如果是这样的话我会努力改正。&#9314;如果我找不到原因，我会找机会跟他们沟通，请他们指出我的不足，有问题就及时改正。&#9315;作为优秀的员工，应该时刻以大局为重，即使在一段时间内，领导和同事对我不理解，我也会做好本职工作，虚心向他们学习，我相信，他们会看见我在努力，总有一天会对我微笑的。<br />9、你对于我们公司了解多少？<br />回答提示：在去公司面试前上网查一下该公司主营业务。如回答：贵公司有意改变策略，加强与国外大厂的OEM合作，自有品牌的部分则透过海外经销商。<br />10、最能概括你自己的三个词是什么？<br />回答提示：我经常用的三个词是：适应能力强，有责任心和做事有始终，结合具体例子向主考官解释，<br />11、你的业余爱好是什么？<br />回答提示：找一些富于团体合作精神的，这里有一个真实的故事：有人被否决掉，因为他的爱好是深海潜水。主考官说：因为这是一项单人活动，我不敢肯定他能否适应团体工作。<br />12、作为被面试者给我打一下分？<br />回答提示：试着列出四个优点和一个非常非常非常小的缺点（可以抱怨一下设施，没有明确责任人的缺点是不会有人介意的）。<br />13、你为什么要离开原来的公司?<br />回答提示：&#9312;回答这个问题时一定要小心，就算在前一个工作受到再大的委屈，对公司有多少的怨言，都千万不要表现出来，尤其要避免对公司本身主管的批评，避免面试官的负面情绪及印象。建议此时最好的回答方式是将问题归咎在自己身上，例如觉得工作没有学习发展的空间，自己想在面试工作的相关产业中多加学习，或是前一份工作与自己的生涯规划不合等等，回答的答案最好是积极正面的。&#9313;我希望能获得一份更好的工作，如果机会来临，我会抓住。我觉得目前的工作，已经达到顶峰，即沒有升迁机会。<br />14、你欣赏哪种性格的人？<br />回答提示：诚实、不死板而且容易相处的人、有&#8220;实际行动&#8221;的人。<br />15、你通常如何对待别人的批评？<br />回答提示：&#9312;沈默是金，不必说什么，否则情况更糟，不过我会接受建设性的批评。&#9313;我会等大家冷靜下来再讨论。<br />16、怎样对待自己的失败？<br />回答提示：我们大家生来都不是十全十美的，我相信我有第二个机会改正我的错误。<br />17、你为什么愿意到我们公司来工作？<br />回答提示：对于这个问题，你要格外小心，如果你已经对该单位作了研究，你可以回答一些详细的原因，像&#8220;公司本身的高技术开发环境很吸引我。&#8221;、&#8220;我同公司出生在同样的时代，我希望能够进入一家与我共同成长的公司。&#8221;、&#8220;你们公司一直都稳定发展，在近几年来在市场上很有竞争力。&#8221;、&#8220;我认为贵公司能够给我提供一个与众不同的发展道路。&#8221;这都显示出你已经做了一些调查，也说明你对自己的未来有了较为具体的远景规划。<br />18、对这项工作，你有哪些可预见的困难？<br />回答提示：&#9312;不宜直接说出具体的困难，否则可能令对方怀疑应聘者不行。&#9313;可以尝试迂回战术，说出应聘者对困难所持有的态度&#8212;&#8212;工作中出现一些困难是正常的，也是难免的，但是只要有坚忍不拔的毅力、良好的合作精神以及事前周密而充分的准备，任何困难都是可以克服。<br />19、如果录用了你，你将怎样开展工作？<br />回答提示： &#9312;如果应聘者对于应聘的职位缺乏足够的了解，最好不要直接说出自己开展工作的具体办法。&#9313;可以尝试采用迂回战术来回答，如&#8220;首先听取领导的指示和要求，然后就有关情况进行了解和熟悉，接下来制定一份近期的工作计划并报领导批准，最后根据计划开展工作。&#8221;。<br />分析：这个问题的主要目的也是了解应聘者的工作能力和计划性、条理性，而且重点想要知道细节。如果向思路中所讲的迂回战术，面试官会认为回避问题，如果引导了几次仍然是回避的话，此人绝对不会录用了。<br />20、你希望与什么样的上级共事？<br />回答提示：&#9312;通过应聘者对上级的&#8220;希望&#8221;可以判断出应聘者对自我要求的意识，这既上一个陷阱，又是一次机会。&#9313;最好回避对上级具体的希望，多谈对自己的要求。&#9314;如&#8220;做为刚步入社会的新人，我应该多要求自己尽快熟悉环境、适应环境，而不应该对环境提出什么要求，只要能发挥我的专长就可以了。<br />分析：这个问题比较好的回答是，希望我的上级能够在工作中对我多指导，对我工作中的错误能够立即指出。总之，从上级指导这个方面谈，不会有大的纰漏。<br />21、与上级意见不一时，你将怎么办？<br />回答提示：&#9312;一般可以这样回答&#8220;我会给上级以必要的解释和提醒，在这种情况下，我会服从上级的意见。&#8221;&#9313;如果面试你的是总经理，而你所应聘的职位另有一位经理，且这位经理当时不在场，可以这样回答：&#8220;对于非原则性问题，我会服从上级的意见，对于涉及公司利益的重大问题，我希望能向更高层领导反映。&#8221;<br />分析：这个问题的标准答案是思路&#9312;，如果用&#9313;的回答，必死无疑。你没有摸清楚改公司的内部情况，先想打小报告，这样的人没有人敢要。<br />22、为什么选择我们公司？<br />回答提示：曾经在报章杂志看过关于贵公司的报道，与自己所追求的理念有志一同。而贵公司在业界的成绩也是有目共睹的，而且对员工的教育训练、升迁等也都很有制度。<br />分析：去面试前先做功课，了解一下该公司的背景，让对方觉得你真的很有心想得到这份工作，而不只是探探路。<br />23、谈谈如何适应办公室工作的新环境？<br />回答提示&#9312;办公室里每个人有各自的岗位与职责，不得擅离岗位。&#9313;根据领导指示和工作安排，制定工作计划，提前预备，并按计划完成。&#9314;多请示并及时汇报，遇到不明白的要虚心请教。&#9315;抓间隙时间，多学习，努力提高自己的政治素质和业务水平。<br />24、除了本公司外，还应聘了哪些公司？<br />回答提示：很奇怪，这是相当多公司会问的问题，其用意是要概略知道应徵者的求职志向，所以这并非绝对是负面答案，就算不便说出公司名称，也应回答&#8220;销售同种产品的公司&#8221;，如果应聘的其他公司是不同业界，容易让人产生无法信任的感觉。<br />25、你还有什么问题要问吗？<br />回答提示：企业的这个问题看上去可有可无，其实很关键，企业不喜欢说&#8220;没问题&#8221;的人，因为其很注重员工的个性和创新能力。企业不喜欢求职者问个人福利之类的问题，如果有人这样问：贵公司对新入公司的员工有没有什么培训项目，我可以参加吗？或者说贵公司的晋升机制是什么样的？企业将很欢迎，因为体现出你对学习的热情和对公司的忠诚度以及你的上进心。<br />26、如果你被录用，何时可以到职？<br />回答提示：大多数企业会关心就职时间，最好是回答&#8220;如果被录用的话，到职日可按公司规定上班&#8221;，但如果还未辞去上一个工作、上班时间又太近，似乎有些强人所难，因为交接至少要一个月的时间，应进一步说明原因，录取公司应该会通融的。</p>
<p>&nbsp;</p>
<p>本文来自CSDN博客，转载请标明出处：<a href="http://blog.csdn.net/dy_Learning/archive/2011/04/02/6298747.aspx">http://blog.csdn.net/dy_Learning/archive/2011/04/02/6298747.aspx</a></p><img src ="http://www.cppblog.com/Walker/aggbug/146843.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Walker/" target="_blank">漫步者×&……%￥</a> 2011-05-21 07:40 <a href="http://www.cppblog.com/Walker/articles/146843.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>火车运煤问题(转)</title><link>http://www.cppblog.com/Walker/articles/143965.html</link><dc:creator>漫步者×&amp;……%￥</dc:creator><author>漫步者×&amp;……%￥</author><pubDate>Mon, 11 Apr 2011 11:36:00 GMT</pubDate><guid>http://www.cppblog.com/Walker/articles/143965.html</guid><wfw:comment>http://www.cppblog.com/Walker/comments/143965.html</wfw:comment><comments>http://www.cppblog.com/Walker/articles/143965.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Walker/comments/commentRss/143965.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Walker/services/trackbacks/143965.html</trackback:ping><description><![CDATA[<p style="PADDING-LEFT: 30px"><strong><span style="COLOR: #008000">你是山西的一个煤老板，你在矿区开采了有3000吨煤需要运送到市场上去卖，从你的矿区到市场有1000公里，你手里有一列烧煤的火车，这个火车最多只能装1000吨煤，且其能耗比较大——每一公里需要耗一吨煤。请问，作为一个懂编程的煤老板的你，你会怎么运送才能运最多的煤到集市？</span></strong></p>
火车运行时，最好让他满载，起始点记为A<br>第一步，分三次把煤运送到中间点B<br>第二步，分两次把煤运送到中间点C<br>第三步，把煤运送到目的地D<br>第一步：5*(AB) = 1000；解得AB=200<br>第二步：3*BC = 1000；解得BC=333.<br>第三步：AB+BC+CD=1000；解得CD=467<br>因此，做多运送533吨煤到目的地<br><br>假定从A到B需要2m+1次，距离为x，那么运过去消耗(2m+1)x的煤。一开始的时候必须(m+1)&gt;=3才可以把煤运完，而且空载是没有哦效率的，所以(m+1)&lt;4.<br>所以m=2，而m=1是，所剩煤为2000，m=0时，所剩煤为1000.由m值可以得到距离x，和9楼一样。<br>同时，在m不变的情况下，可以任意分段，比如m=2是，可以把煤运到50处，然后在运到100处，然后再运到200处，由于m都是等于2，所以到200时，总会剩下2000煤。<br>所以实际上解有无群多，只要让煤在200，533的地方重新聚集就行了。<br><br>首先，要获得最大值，必须在最远的中间&#8221;补给点&#8221;放下等同其路程的煤作为补给。所以接下来要做的就是，如何让2000吨煤放到最远的地方，同时留下&#8220;补给煤&#8221;。因为条件限制，所以只能分两次达成上面的目标，第一个补给点，他要消耗的是他路程的5倍的煤，因为他自己消耗两次，第二次送煤的消耗两次，最后一次直达终点的要消耗一次。所以他要在1/5的地方放下，第一个点已经提供补给，所以第二点要补给3次，他自己两次，最后直达的一次。所以是在200+333的地方放下333.所以最后到达的，应该是200+333 = 533. 总数是其他值也可以推导出来了<br>编程的例子就是：
<p>int sum = 3000;<br>int load_num = 1000;</p>
<p>int result = 0;<br>int time = sum / load_num &#8211; 1;<br>for (int i = time; i &gt; 0 ; &#8211;i) {<br>result += load_num / ((i*2) + 1);<br>}</p>
<img src ="http://www.cppblog.com/Walker/aggbug/143965.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Walker/" target="_blank">漫步者×&……%￥</a> 2011-04-11 19:36 <a href="http://www.cppblog.com/Walker/articles/143965.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Google笔试题2</title><link>http://www.cppblog.com/Walker/articles/136336.html</link><dc:creator>漫步者×&amp;……%￥</dc:creator><author>漫步者×&amp;……%￥</author><pubDate>Mon, 13 Dec 2010 14:16:00 GMT</pubDate><guid>http://www.cppblog.com/Walker/articles/136336.html</guid><description><![CDATA[<h2>140个Google的面试题</h2>
<div class=info><span class=date>2010年12月2日</span> <span class=author><a title="由 陈皓 发表" href="http://coolshell.cn/articles/author/haoel/"><u><font color=#0000ff>陈皓</font></u></a></span> <span class=addcomment><a href="http://coolshell.cn/articles/3345.html#respond"><u><font color=#0000ff>发表评论</font></u></a></span> <span class=comments><a href="http://coolshell.cn/articles/3345.html#comments"><u><font color=#0000ff>阅读评论</font></u></a></span> <span class=comments>4,360 次点击 &nbsp; &nbsp;</span>
<div class=fixed></div>
</div>
<div class=content>
<p>来源：<a onclick="pageTracker._trackPageview('/outgoing/blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html?referer=');" href="http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html" target=_blank><u><font color=#0000ff>http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html</font></u></a>（墙）<br><img class="alignright size-medium wp-image-3349" title="Google 面试题 " alt="" src="http://coolshell.cn/wp-content/uploads/2010/12/googlequestion-300x225.jpg" width=210 height=158></p>
<div>某猎头收集了140多个Google的面试题，都张到他的Blog中了，主要是下面这些职位的，因为被墙，且无任何敏感信息，所以，我原文搬过来了。</div>
<div>
<ul>
    <li>Product Marketing Manager
    <li>Product Manager
    <li>Software Engineer
    <li>Software Engineer in Test
    <li>Quantitative Compensation Analyst
    <li>Engineering Manager
    <li>AdWords Associate </li>
</ul>
</div>
<p>这篇Blog例举了Google用来面试下面这几个职位的面试题。很多不是很容易回答，不过都比较经典与变态，是Google，Microsoft，Amazon之类的公司的风格。对于本文，我没有翻译，因为我相信，英文问题是最好的。不过对于有些问题，我做了一些注释，不一定对，但希望对你有帮助启发。对于一些问题，如果你百思不得其解，可以Google一下，StackOverflow或是Wikipedia上可能会给你非常全面的答案。</p>
<p><span id=more-3345></span></p>
<div><strong>Product Marketing Manager</strong></div>
<div>
<div>
<ul>
    <li>Why do you want to join Google?
    <li>What do you know about Google&#8217;s product and technology?
    <li>If you are Product Manager for Google&#8217;s Adwords, how do you plan to market this?
    <li>What would you say during an AdWords or AdSense product seminar?
    <li>Who are Google&#8217;s competitors, and how does Google compete with them?
    <li>Have you ever used Google&#8217;s products? Gmail?
    <li>What&#8217;s a creative way of marketing Google&#8217;s brand name and product?
    <li>If you are the product marketing manager for Google&#8217;s Gmail product, how do you plan to market it so as to achieve 100 million customers in 6 months?
    <li>How much money you think Google makes daily from Gmail ads?
    <li>Name a piece of technology you&#8217;ve read about recently. Now tell me your own creative execution for an ad for that product.
    <li>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?<span style="WHITE-SPACE: pre"> </span>
    <li>Estimate the number of students who are college seniors, attend four-year schools, and graduate with a job in the United States every year. </li>
</ul>
</div>
</div>
<div><strong>Product Manager</strong></div>
<div>
<div>
<ul>
    <li>How would you boost the GMail subscription base?
    <li>What is the most efficient way to sort a million integers? &nbsp;（陈皓：merge sort）
    <li>How would you re-position Google&#8217;s offerings to counteract competitive threats from Microsoft?
    <li>How many golf balls can fit in a school bus? （陈皓：这种题一般来说是考你的解题思路的，注意，你不能单纯地把高尔夫球当成一个小立方体，其是一个圆球，堆起来的时候应该是错开的——也就是三个相邻的球的圆心是个等边三角形）
    <li>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?
    <li>How much should you charge to wash all the windows in Seattle?
    <li>How would you find out if a machine&#8217;s stack grows up or down in memory?
    <li>Explain a database in three sentences to your eight-year-old nephew. （陈皓：用三句话向8岁的侄子解释什么是数据库，考你的表达能力了）
    <li>How many times a day does a clock&#8217;s hands overlap?（陈皓：经典的时钟问题）
    <li>You have to get from point A to point B. You don&#8217;t know if you can get there. What would you do?
    <li>Imagine you have a closet full of shirts. It&#8217;s very hard to find a shirt. So what can you do to organize your shirts for easy retrieval? （陈皓：很不错的一道题，不要以为分类查询很容易，想想图书馆图书的分类查询问题吧。另外，你处想想如何在你在你的衣柜里实现一个相当于Hash表或是一个Tree之类的数据结构）
    <li>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们的递归，这类的问题是经典的分布式通讯问题，上网搜 一搜吧。）
    <li>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%的概率是永远不变的。）
    <li>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)?
    <li>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!)
    <li>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&#8217;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?（陈皓：经典的过桥问题）
    <li>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?
    <li>How many piano tuners are there in the entire world?
    <li>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?（陈皓：经典的称重问题。这样的问题花样很多，不过都不难回答）
    <li>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.)
    <li>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. （陈皓：从3的倍数的楼层开始扔，比如3，6，9，12&#8230;..，如果鸡蛋在3n层碎了，那到在3n-1层扔第二个鸡蛋，如果没碎，则最高不碎楼层为3n-1，否则为3n-2）
    <li>Describe a technical problem you had and how you solved it.
    <li>How would you design a simple search engine?
    <li>Design an evacuation plan for San Francisco.
    <li>There&#8217;s a latency problem in South Africa. Diagnose it. （陈皓：这个问题完全是在考你的解决问题的能力。没有明确的答案。不过，解决性能问题的第一步通常是找出瓶颈，找瓶颈有很多种方法，工具，二分查，时间记录等等。）
    <li>What are three long term challenges facing Google?
    <li>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?
    <li>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? （陈皓：经典的电梯设计问题，这种问题千变万化，主要是考你的设计能力和需求变化的适变能力，与此相似的是酒店订房系统。）
    <li>How many vacuum&#8217;s are made per year in USA? </li>
</ul>
</div>
</div>
<div>
<div><strong>Software Engineer</strong></div>
<div>
<div>
<ul>
    <li>Why are manhole covers round? （陈皓：为什么下水井盖是圆的？这是有N种答案的，上Wiki看看吧）
    <li>What is the difference between a mutex and a semaphore? Which one would you use to protect access to an increment operation?
    <li>A man pushed his car to a hotel and lost his fortune. What happened? （陈皓：脑筋急转弯？他在玩大富翁游戏？！！）
    <li>Explain the significance of &#8220;dead beef&#8221;.（陈皓：要是你看到的是16进制 DEAD BEEF，你会觉得这是什么？IPv6的地址？）
    <li>Write a C program which measures the the speed of a context switch on a UNIX/Linux system.
    <li>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看看吧，经典的问题）
    <li>Describe the algorithm for a depth-first graph traversal.
    <li>Design a class library for writing card games. （陈皓：用一系列的类来设计一个扑克游戏，设计题）
    <li>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?（陈皓：协议+数字加密，我试想了一个，纸条上可以这样写，&#8220;Bob，请把我的手机号以MD5算法加密后的字符串，比对下面的字符串——XXXXXX，它们是一样的吗？&#8221;）
    <li>How are cookies passed in the HTTP protocol?
    <li>Design the SQL database tables for a car rental database.
    <li>Write a regular expression which matches a email address. （陈皓：上StackOverflow查相当的问题吧。）
    <li>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)的算法复杂度）
    <li>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? （陈皓：和随机数有关系？或是时间？）
    <li>Explain how congestion control works in the TCP protocol.
    <li>In Java, what is the difference between final, finally, and finalize?
    <li>What is multithreaded programming? What is a deadlock?
    <li>Write a function (with helper functions if needed) called to Excel that takes an excel column value (A,B,C,D&#8230;AA,AB,AC,&#8230; AAA..) and returns a corresponding integer value (A=1,B=2,&#8230; AA=26..).
    <li>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.
    <li>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.
    <li>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&#8217;t know where the circular list begins, ie: 38, 40, 55, 89, 6, 13, 20, 23, 36. （陈皓：循环排序数组的二分查找问题）
    <li>Describe the data structure that is used to manage memory. (stack)
    <li>What&#8217;s the difference between local and global variables?
    <li>If you have 1 million integers, how would you sort them efficiently? (modify a specific sorting algorithm to solve this)
    <li>In Java, what is the difference between static, final, and const. (if you don&#8217;t know Java they will ask something similar for C or C++).
    <li>Talk about your class projects or work projects (pick something easy)&#8230; then describe how you could make them more efficient (in terms of algorithms).
    <li>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.（陈皓：以前见过一维数组的这个问题，现在是二维的。感觉应该是把二维的第一行的最大和的区间算出来，然后再在这个基础之上进行二维的分析。思路应该是这个，不过具体的算法还需要想一想）
    <li>Write some code to reverse a string.
    <li>Implement division (without using the divide operator, obviously).（陈皓：想一想手算除法的过程。）
    <li>Write some code to find all permutations of the letters in a particular string.
    <li>What method would you use to look up a word in a dictionary? （陈皓：使用排序，哈希，树等算法和数据结构）
    <li>Imagine you have a closet full of shirts. It&#8217;s very hard to find a shirt. So what can you do to organize your shirts for easy retrieval?
    <li>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?
    <li>What is the C-language command for opening a connection with a foreign host over the internet?
    <li>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&#8217;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.
    <li>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&lt;n-1; i++){ Output[i]=r; r*=a[i]; }，看明白了吧。第二次的循环我就不说了，方法一样的。）
    <li>There is a linked list of numbers of length N. N is very large and you don&#8217;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个随机数和其链接地址。）
    <li>Find or determine non existence of a number in a sorted list of N numbers where the numbers range over M, M&gt;&gt; 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）
    <li>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.
    <li>You are given an array [a1 To an] and we have to construct another array [b1 To bn] where bi = a1*a2*&#8230;*an/ai. you are allowed to use only constant space and the time complexity is O(n). No divisions are allowed.（陈皓：前面说过了）
    <li>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.（陈皓：按顺序遍历树）
    <li>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.
    <li>Given a Data Structure having first n integers and next n chars. A = i1 i2 i3 &#8230; iN c1 c2 c3 &#8230; cN.Write an in-place algorithm to rearrange the elements of the array ass A = i1 c1 i2 c2 &#8230; in cn（陈皓：这个算法其实就是从中间开始交换元素，代码：for(i=n-1; i&gt;1; i++) { &nbsp;for(j=i; j&lt;2*n-i; j+=2) { swap(a[j], a[j+1]); } }，不好意思写在同一行上了。）
    <li>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.
    <li>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?
    <li>How many lines can be drawn in a 2D plane such that they are equidistant from 3 non-collinear points?
    <li>Let&#8217;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?
    <li>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?
    <li>Given a binary tree, programmatically you need to prove it is a binary search tree.
    <li>You are given a small sorted list of numbers, and a very very long sorted list of numbers &#8211; 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?
    <li>Suppose you have given N companies, and we want to eventually merge them into one big company. How many ways are theres to merge?
    <li>Given a file of 4 billion 32-bit integers, how to find one that appears at least twice? （陈皓：我能想到的是拆分成若干个小数组，排序，然后一点点归并起来）
    <li>Write a program for displaying the ten most frequent words in a file such that your program should be efficient in all complexity measures.（陈皓：你可能需要看看这篇文章<a onclick="pageTracker._trackPageview('/outgoing/www.cs.rutgers.edu/_farach/pubs/FrequentStream.pdf?referer=');" href="http://www.cs.rutgers.edu/~farach/pubs/FrequentStream.pdf" target=_blank><span style="TEXT-DECORATION: underline"><font color=#0000ff>Finding Frequent Items in Data Streams</font></span></a>）
    <li>Design a stack. We want to push, pop, and also, retrieve the minimum element in constant time.
    <li>Given a set of coin denominators, find the minimum number of coins to give a certain amount of change.（陈皓：你应该查看一下这篇文章：<a onclick="pageTracker._trackPageview('/outgoing/www.algorithmist.com/index.php/Coin_Change?referer=');" href="http://www.algorithmist.com/index.php/Coin_Change" target=_blank><span style="TEXT-DECORATION: underline"><font color=#0000ff>Coin Change Problem</font></span></a>）
    <li>Given an array, i) find the longest continuous increasing subsequence. ii) find the longest increasing subsequence.（陈皓：这个题不难，O(n)算法是边遍历边记录当前最大的连续的长度。）
    <li>Suppose we have N companies, and we want to eventually merge them into one big company. How many ways are there to merge?
    <li>Write a function to find the middle node of a single link list. （陈皓：我能想到的算法是——设置两个指针p1和p2，每一次，p1走两步，p2走一步，这样，当p1走到最后时，p2就在中间）
    <li>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.（陈皓：这个很简单，使用递归算法。）
    <li>Implement put/get methods of a fixed size cache with LRU replacement algorithm.
    <li>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]))&#8221; Please give a solution in O(n) time complexity（陈皓：三个指针，a, b, c分别指向三个数组头，假设：a[0]&lt;b[0]&lt;c[0]，推进a直到a[i]&gt;b[0]，计算 abs(a[i-1] &#8211; c[0])，把结果保存在min中。现在情况变成找 a[i], b[0],c[0]，重复上述过程，如果有一个新的值比min要小，那就取代现有的min。）
    <li>How does C++ deal with constructors and deconstructors of a class and its child class?
    <li>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.
    <li>What&#8217;s 2 to the power of 64?
    <li>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个字串中以二分取中的方式查找。）
    <li>How do you find out the fifth maximum element in an Binary Search Tree in efficient manner.
    <li>Suppose we have N companies, and we want to eventually merge them into one big company. How many ways are there to merge?
    <li>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.
    <li>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?
    <li>How long it would take to sort 1 trillion numbers? Come up with a good estimate.
    <li>Order the functions in order of their asymptotic performance: 1) 2^n 2) n^100 3) n! 4) n^n
    <li>There are some data represented by(x,y,z). Now we want to find the Kth least data. We say (x1, y1, z1) &gt; (x2, y2, z2) when value(x1, y1, z1) &gt; 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?
    <li>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?
    <li>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.
    <li>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表，然后遍历第二个链表。不知道还没有更好的方法。）
    <li>What&#8217;s the difference between a hashtable and a hashmap?
    <li>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?（陈皓：这个问题和美国的电话有关系，大家可以试着想一下我们发短信的手机，按数字键出字母，一个组合的数学问题。）
    <li>How would you reverse the image on an n by n matrix where each pixel is represented by a bit?
    <li>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).
    <li>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.
    <li>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.
    <li>What sort would you use if you had a large data set on disk and a small amount of ram to work with?
    <li>What sort would you use if you required tight max time bounds and wanted highly regular performance.
    <li>How would you store 1 million phone numbers?（陈皓：试想电话是有区段的，可以把区段统一保存，Flyweight设计模式）
    <li>Design a 2D dungeon crawling game. It must allow for various items in the maze &#8211; 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.)
    <li>What is the size of the C structure below on a 32-bit system? On a 64-bit? （陈皓：注意编译器的对齐） </li>
</ul>
<p style="PADDING-LEFT: 90px">struct foo {</p>
<div style="PADDING-LEFT: 90px">char a;</div>
<div style="PADDING-LEFT: 90px">char* b;</div>
<div style="PADDING-LEFT: 90px">};</div>
</div>
</div>
<div><strong>Software Engineer in Test</strong></div>
<div>
<ul>
    <li>Efficiently implement 3 stacks in a single array.
    <li>Given an array of integers which is circularly sorted, how do you find a given integer.
    <li>Write a program to find depth of binary search tree without using recursion.
    <li>Find the maximum rectangle (in terms of area) under a histogram in linear time.
    <li>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.
    <li>Describe recursive mergesort and its runtime. Write an iterative version in C++/Java/Python.
    <li>How would you determine if someone has won a game of tic-tac-toe on a board of any size?
    <li>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.
    <li>Create a cache with fast look up that only stores the N most recently accessed items.
    <li>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?
    <li>Given two files that has list of words (one per line), write a program to show the intersection.
    <li>What kind of data structure would you use to index annagrams of words? e.g. if there exists the word &#8220;top&#8221; in the database, the query for &#8220;pot&#8221; should list that. </li>
</ul>
<div>
<div><strong>Quantitative Compensation Analyst</strong></div>
</div>
</div>
<div>
<ul>
    <li>What is the yearly standard deviation of a stock given the monthly standard deviation?
    <li>How many resumes does Google receive each year for software engineering?
    <li>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?
    <li>What is the probability of breaking a stick into 3 pieces and forming a triangle? </li>
</ul>
</div>
<div><strong>Engineering Manager</strong></div>
<div>
<ul>
    <li>You&#8217;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? </li>
</ul>
</div>
<div><strong>AdWords Associate</strong></div>
<div>
<ul>
    <li>How would you work with an advertiser who was not seeing the benefits of the AdWords relationship due to poor conversions?
    <li>How would you deal with an angry or frustrated advertisers on the phone? </li>
</ul>
</div>
<div><span style="FONT-SIZE: small"><em>Sources</em></span></div>
<div style="PADDING-LEFT: 30px"><span><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/news.ycombinator.com/item?id=266663&amp;referer=');" href="http://news.ycombinator.com/item?id=266663" target=_blank><u><font color=#0000ff>http://news.ycombinator.com/item?id=266663</font></u></a> </span></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/tihomir.org/crazy-questions-at-google-job-interview/?referer=');" href="http://tihomir.org/crazy-questions-at-google-job-interview/" target=_blank><font color=#0000ff><u>http://tihomir.org/crazy-questions-at-google-job-interview/</u></font></a><br></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/www.drizzle.com/_jpaint/google.html?referer=');" href="http://www.drizzle.com/~jpaint/google.html" target=_blank><font color=#0000ff><u>http://www.drizzle.com/~jpaint/google.html</u></font></a><br></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/www.gamedev.net/community/forums/topic.asp?topic_id=299692&amp;referer=');" href="http://www.gamedev.net/community/forums/topic.asp?topic_id=299692" target=_blank><font color=#0000ff><u>http://www.gamedev.net/community/forums/topic.asp?topic_id=299692</u></font></a><br></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/careers.cse.sc.edu/googleinterview?referer=');" href="http://careers.cse.sc.edu/googleinterview" target=_blank><font color=#0000ff><u>http://careers.cse.sc.edu/googleinterview</u></font></a><br></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/job-interview.blogspot.com/2005/02/google-interview-product-marketing.html?referer=');" href="http://job-interview.blogspot.com/2005/02/google-interview-product-marketing.html" target=_blank><font color=#0000ff><u>http://job-interview.blogspot.com/2005/02/google-interview-product-marketing.html</u></font></a><br></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/www.theregister.co.uk/2007/01/05/google_interview_tales/?referer=');" href="http://www.theregister.co.uk/2007/01/05/google_interview_tales/" target=_blank><font color=#0000ff><u>http://www.theregister.co.uk/2007/01/05/google_interview_tales/</u></font></a><br></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/money.cnn.com/2007/08/29/technology/brain_teasers.biz2/index.htm?referer=');" href="http://money.cnn.com/2007/08/29/technology/brain_teasers.biz2/index.htm" target=_blank><font color=#0000ff><u>http://money.cnn.com/2007/08/29/technology/brain_teasers.biz2/index.htm</u></font></a><br></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/money.cnn.com/2007/08/29/technology/brain_teasers.biz2/index.htm?referer=');" href="http://money.cnn.com/2007/08/29/technology/brain_teasers.biz2/index.htm" target=_blank><font color=#0000ff><u>http://blogs.lessthandot.com/index.php/ITProfessionals/EthicsIT/google-interview-questions</u></font></a><br></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/placementsindia.blogspot.com/2007/09/google-top-interview-puzzles.html?referer=');" href="http://placementsindia.blogspot.com/2007/09/google-top-interview-puzzles.html" target=_blank><font color=#0000ff><u>http://placementsindia.blogspot.com/2007/09/google-top-interview-puzzles.html</u></font></a><br></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/linkmingle.com/user/interview_questions/google_interview_questions?referer=');" href="http://linkmingle.com/user/interview_questions/google_interview_questions" target=_blank><font color=#0000ff><u>http://linkmingle.com/user/interview_questions/google_interview_questions</u></font></a><br></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/discuss.joelonsoftware.com/default.asp?interview.11.626758.33&amp;referer=');" href="http://discuss.joelonsoftware.com/default.asp?interview.11.626758.33" target=_blank><font color=#0000ff><u>http://discuss.joelonsoftware.com/default.asp?interview.11.626758.33</u></font></a><br></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/mindcipher.com/puzzle/78-clock-works?referer=');" href="http://mindcipher.com/puzzle/78-clock-works" target=_blank><font color=#0000ff><u>http://mindcipher.com/puzzle/78-clock-works</u></font></a><br></span></div>
<div style="PADDING-LEFT: 30px"><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/www.glassdoor.com?referer=');" href="http://www.glassdoor.com/" target=_blank><font color=#0000ff><u>http://www.glassdoor.com</u></font></a></span></div>
<div style="PADDING-LEFT: 30px">
<div><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/bluepixel.ca/blog/?p=69&amp;referer=');" href="http://bluepixel.ca/blog/?p=69" target=_blank><font color=#0000ff><u>http://bluepixel.ca/blog/?p=69</u></font></a></span></div>
<div><span style="FONT-SIZE: small"></span><span style="FONT-SIZE: small"><a onclick="pageTracker._trackPageview('/outgoing/www.businessinsider.com/my-nightmare-interviews-with-google-2009-11?referer=');" href="http://www.businessinsider.com/my-nightmare-interviews-with-google-2009-11" target=_blank><u><font color=#810081>http://www.businessinsider.com/my-nightmare-interviews-with-google-2009-11</font></u></a></span></div>
<div><span style="FONT-SIZE: small"><br><u><font color=#810081></font></u></span></div>
</div>
</div>
<p>（全文完）</p>
</div>
<img src ="http://www.cppblog.com/Walker/aggbug/136336.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Walker/" target="_blank">漫步者×&……%￥</a> 2010-12-13 22:16 <a href="http://www.cppblog.com/Walker/articles/136336.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>google笔试题</title><link>http://www.cppblog.com/Walker/articles/136335.html</link><dc:creator>漫步者×&amp;……%￥</dc:creator><author>漫步者×&amp;……%￥</author><pubDate>Mon, 13 Dec 2010 14:01:00 GMT</pubDate><guid>http://www.cppblog.com/Walker/articles/136335.html</guid><description><![CDATA[<h1 class=postTitle><a id=ctl04_TitleUrl class=postTitle2 href="http://www.cnblogs.com/chio/archive/2007/09/16/894806.html"><font color=#399ab2>google笔试题收集</font></a> </h1>
<div class=clear></div>
<div class=postBody>
<p><img border=0 alt="" src="http://images.cnblogs.com/cnblogs_com/chio/google1.jpg" width=613 height=496 twffan="done"></p>
</div>
<br>1. 异或<br>1^1=0<br>0^0=0<br>1^0=1<br>0^1=1<br><br>2. 斐波那契数列(Fibonacci)<br><br>3.存储空间上不具有优势<br><br>4. 由&#8220;主定理&#8221;<br>T(n)=25T(n/5) + n<font size=2><sup>2</sup><br><br></font>a=25&nbsp; b=5&nbsp;&nbsp; f(n)=n<font size=2><sup>2</sup><br></font>log<sub><font size=2>b</font></sub>a=2<br><br>将n<sup><font size=2>log</font><sub><font size=1>b</font></sub><font size=2>a</font></sup>与f(n)比较： 相等<br>则时间复杂度为O(n<sup><font size=2>2</font></sup>logn)<br><br><img border=0 alt="" src="http://images.cnblogs.com/cnblogs_com/chio/google2.jpg" twffan="done"><br><br>1. <br>
<p>&nbsp;</p>
<p>2.&nbsp;<br><br>3</p>
<div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px" class=code twffan="done"><span style="COLOR: #000000" twffan="done">#include&nbsp;</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">iostream</span><span style="COLOR: #000000" twffan="done">&gt;</span><span style="COLOR: #000000" twffan="done"><br>#include&nbsp;</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">limits</span><span style="COLOR: #000000" twffan="done">&gt;</span><span style="COLOR: #000000" twffan="done"><br></span><span style="COLOR: #0000ff" twffan="done">using</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #0000ff" twffan="done">namespace</span><span style="COLOR: #000000" twffan="done">&nbsp;std;<br><br></span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;foo(</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;arr[],&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;n)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;max&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;numeric_limits</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&gt;</span><span style="COLOR: #000000" twffan="done">::min();<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000" twffan="done">//</span><span style="COLOR: #008000" twffan="done">cout&nbsp;&lt;&lt;&nbsp;max&nbsp;&lt;&lt;&nbsp;"\n";</span><span style="COLOR: #008000" twffan="done"><br></span><span style="COLOR: #000000" twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">(</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;i&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;i&nbsp;</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">&nbsp;n;&nbsp;i</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;product&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">(</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;j&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;j&nbsp;</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">&nbsp;n;&nbsp;j</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">(j&nbsp;</span><span style="COLOR: #000000" twffan="done">!=</span><span style="COLOR: #000000" twffan="done">&nbsp;i&nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;product&nbsp;</span><span style="COLOR: #000000" twffan="done">*=</span><span style="COLOR: #000000" twffan="done">&nbsp;arr[j];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;max&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;product&nbsp;</span><span style="COLOR: #000000" twffan="done">&gt;</span><span style="COLOR: #000000" twffan="done">&nbsp;max&nbsp;</span><span style="COLOR: #000000" twffan="done">?</span><span style="COLOR: #000000" twffan="done">&nbsp;product&nbsp;:&nbsp;max;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">return</span><span style="COLOR: #000000" twffan="done">&nbsp;max;<br>}<br><br></span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;main()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;arr[</span><span style="COLOR: #000000" twffan="done">4</span><span style="COLOR: #000000" twffan="done">]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;{&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">,&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">5</span><span style="COLOR: #000000" twffan="done">,&nbsp;</span><span style="COLOR: #000000" twffan="done">2</span><span style="COLOR: #000000" twffan="done">,&nbsp;</span><span style="COLOR: #000000" twffan="done">3</span><span style="COLOR: #000000" twffan="done">};<br>&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="COLOR: #000000" twffan="done">&lt;&lt;</span><span style="COLOR: #000000" twffan="done">&nbsp;foo(arr,&nbsp;</span><span style="COLOR: #000000" twffan="done">4</span><span style="COLOR: #000000" twffan="done">)&nbsp;</span><span style="COLOR: #000000" twffan="done">&lt;&lt;</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">\n</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">return</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;<br>}</span></div>
<p>时间复杂度分析:<br>总共的操作步骤 n*{[n+(n-1)]+1}=2n<font size=2><sup>2</sup><br></font>时间复杂度为O(n2)<br><br>空间复杂度为O(1)&nbsp; 4*sizeof(int)<br><br><br>改进算法：<br><br>Google笔试集锦<br>Google笔试集锦<br>&nbsp;<br>选择题+三道算法题<br>选择题没什么难的&nbsp; 最后一道考的数据库使用什么存储结构不会做。。<br>算法题<br>第一题没什么好说<br>第二题可破<br></p>
<p>Google笔试集锦<br>Google笔试集锦<br>&nbsp;<br>选择题+三道算法题<br>选择题没什么难的&nbsp; 最后一道考的数据库使用什么存储结构不会做。。<br>算法题<br>第一题没什么好说<br>第二题可破坏一个数组A[0..N-1]的条件下使用最少的内存判断是否存在相同的元素<br>&nbsp;&nbsp; 我的做法是堆排序&nbsp; 时间O(NlogN) 空间O(1) 复杂度上来看应该最优了<br>第三题已知每个点的父节点，求这棵树的最大独立集<br>&nbsp;&nbsp; 用递归求解&nbsp; 类似动态规划&nbsp; 但是不存在重叠子状态&nbsp; 经典算法问题了<br>&nbsp;&nbsp; 预处理每个节点的子节点存在一张表里<br>&nbsp;&nbsp; 时间O(N）空间O(N）<br>大家做的结果是这样吗？<br>发信站: 饮水思源 (2006年10月11日03:06:04 星期三), 站内信件<br>开章明义，我是个废人，上来积攒rp了。<br>在宣讲会的时候，听旁边的师姐说上海只招两个职位每个职位只招一个人。<br>现在后悔只选了北京和上海的SWE了。<br>不过反正&#8230;&#8230;也不指望了。。。</p>
<p>笔试题目：9道单选+3道问答<br>时间：100分钟<br>我做的是B卷。<br>单选题：<br>1，求两个二进制数的异或值，基本上学过一点计算机的东西的人都能对的题目。。<br>2，不记得了。。也是不需要思考的题目。。<br>3，大概是如下的函数：<br>int someFunc(int x){<br>&nbsp;&nbsp;&nbsp; if (x == 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return x + someFunc(x - 1);<br>}<br>问这个计算的是什么。。。<br>4，不记得了。。不需要思考吧。。<br>5，不记得了。。不需要思考吧。。<br>6，参见2，4，5。。<br>7，似乎需要思考一下。。<br>8，问链表结构和数组相比的优势不包括哪项，<br>包括：<br>插入的时间<br>删除的时间<br>存储空间<br>剩下两个不记得了。。<br>9，如下函数：<br>T(x) = 1 (x &lt;= 1)<br>T(n) = 25 T(n/5) + n^2<br>问T(n)随n的增长。<br>选项大概是这样的：<br>O(n^2)，O(n^2logn)等等的。。<br>问答：<br>1，写两个N*N的矩阵的乘法，给出了C的格式，你可以选择你喜欢的语言去写。。<br>int* multi(int* a1, int* a2, int N){<br>}<br>2，寻找一个单向链表的中项，如果存在两个则返回前一个。给出了C的格式，同样你可<br>以选择。。。。<br>struct {<br>&nbsp;&nbsp;&nbsp; Node* next;<br>&nbsp;&nbsp;&nbsp; int value;<br>} Node;<br>Node* someFunc(Node* head){<br>}<br>3，给一个长度为n的整数数组，只允许用乘法不允许用除法，计算任意(n-1)个数的组合<br>乘积中最大的一组。。。写出算法的时空复杂度。<br>ps：怀疑这道题目出错啦。。虽然我也做错了。。。。。。<br>一些补充：<br>1，问答的第一题是google上学期 intern的大题原题；<br>2，google很喜欢考链表，无论intern的面试以及两次的笔试都有这样的题目；<br>3，google一般大题第三道都是写算法的时空复杂度；<br>4，选择题基本上偏简单，但是要做得准确率高似乎并不那么容易；<br>5，根据传言，小道消息，人云亦云以及以讹传讹，google的高速审卷政策来源于审卷时<br>以选择题为主，如果你全对啦，那么恭喜你pass啦；如果你错了好几道，那么下次努力<br>吧，如果还有下次。。。大题基本是做参考的。。。<br>6，选择题很多记不清了，因为一遍做下来的，回去随便扫了两眼。。。加上过了这几个<br>小时，记不得了。希望大家补充修正以及修改。。。<br>7，google会在11号开始3天内发面试通知，据小道消息等等，有四轮面试。bless大家~~ <br>&nbsp;<br>&nbsp;<br>输入a_1,&nbsp;&nbsp; a_2,&nbsp;&nbsp; ...,&nbsp;&nbsp; a_n,&nbsp;&nbsp; b_1,&nbsp;&nbsp; b_2,&nbsp;&nbsp; ...,&nbsp;&nbsp; b_n，如何在O(n)的时间，用O(1)的空间，<br>将这个序列顺序改为a_1,&nbsp;&nbsp; b_1,&nbsp;&nbsp; ...,&nbsp;&nbsp; a_n,&nbsp;&nbsp; b_n。<br>这个问题在瀚海星云上跟出了好几十的跟帖，看看大家有没有什么好的解法！！！ <br>&nbsp;</p>
<p>晚上是google的校园宣讲会<br>先前并没有投简历，但是还是奔了去<br>google的hrjj看起来仿佛没有ibm的那么动人，但却很亲切<br>五点半左右开始，开始前那个hrjj放了些google员工自己拍的mv，<br>比较有意思<br>之后是一个做技术的男生如数家珍的介绍google做的东西<br>之所以称为&#8220;男生&#8221;主要感觉他很学生气。。。讲话并没有那些很商业的调度气氛的东西<br>很理想主义，呵呵，虽然听的很多人打瞌睡<br>他总是说google是个很理想主义的公司，虽然为了生存不得不做一些商业化的事情，但是，google做很多事情都是因为认为觉得有做的价值并且要做好，所以有了googleprint,googleearth,等等<br>不过，google仿佛是一个需要聪明人的公司，接下来的笔试应证了这一点<br>内容很少，甚至简单，选择题可能是送分的，大概10来道，并不难，算些东西，还有一点点程序方面的基础概念，后面是三个算法设计题。<br>第一个，深拷贝一个二叉树。我不明白这道题的动机是什么，我最后很搓得用了递归，虽然明知道这样很耗，可是实在想不起来非递归算法怎么个写法了。<br>第二个，把输入数组随机分配到一个新的数组上，每个数都完全对应一个随机的位置，当然，随即产生函数是提供了的。这个题我想了很久，冲突的时候怎么办？散列？但是那样还是随机的吗？<br>第三个，很ft。居然是C语言的一个作业题。N个人排成圈，从第一个人开始，去掉，隔一个人，去掉下一个，以此类推，要求出最后出局的那个人的位置。并且，要求分析算法的时间、空间复杂度。我感觉这个题表面简单，实际对算法的优化要求很高。一个是空间复杂度，一个是时间复杂度，只是不知道做到什么程度算是极好。<br>仿佛这种类型的考试，大家差不多都能答完，只是如何才能与众不同却让人伤脑筋<br>回来后对google的印象变得很好，至少感觉他们真的是需要人，而不是一个螺丝钉。。。 <br>&nbsp;<br>&nbsp;</p>
<p>昨天，参加了Google春季实习工程师的招聘笔试。这是进入大学以来参加的第一次笔试。<br>可以说，这次笔试也让我更明确了我的学习方向。学习什么技能不重要，重要的是要有扎实基础，数据结构，c++语言等，都要扎实的掌握，不可有丝毫的马虎。于是，渐渐开始后悔了，后悔自己对基础知识没有学好，却又一天到晚想着要学什么什么东西，这真是丢了西瓜捡了芝麻，一点便宜都没有占到啊。<br>还记得昨天的笔试，第一题是有关位操作的，很简单。接下来两题是讲const指针的，这便是我的一个薄弱点，以前一直都没有学好。首先，constchar*p="abcde"，那么，p指向的内容是不可变得，即不能改变*p的值，但是，p却是可变的，即可以这么操作：p=&#8220;12345&#8221;，或者p=newchar[10]，等等；另外，char*constp="abcde"，则表示这是一个指针常量，即p不能指向另外的地址，但是，p指向的内容是可以改变的；还有一个就是常量指针常量，constchar*constp，它是指向常量的常量指针，若初始化的时候，p指向的是一个变量，那么，不能用指针操作来改变变量的值，例如：inta=0;constint*constp=&amp;a;*p=1;//这句或是错误的，但是，可以直接给变量赋值，即a=1；是可以的。<br>接下来几题涉及了算法分析的一些东西，然后是涉及语法分析的正则表达式什么的，这个因为没学过编译，也就不太懂了。接下来是考了抖动。什么是抖动？所谓抖动，主要是由于页面交换过于频繁，而导致时间浪费太多的现象。特别的，在虚拟内存技术下，若工作集大小选的不合适的话，就会有频繁的换入换出，而我们知道，硬盘的读写是需要花费大量时间的，这样，就导致了某进程等待的时间比实际运行的时间多的多。<br>接下来的大题是编程题和算法题，前两题都挺简单的，第一题要求完成双向链表的添加结点，第二题要求比较两字符串的字符出现频率；第三题是个算法题，基本意思很简单，但是，要找到一个好的算法却需要一定的思考能力，具体题目已经记不太清了。<br>总之，这次笔试，虽然说从一开始所抱的心态就是见识见识，没有奢求什么，只是想走出这个温暖的象牙塔，走到外面这个花花世界来看看情形。一切都需放开。走了一遭才发现，不要总往高处看，基础扎实了，才能造起巴比伦塔。<br>&nbsp;<br>&nbsp;<br>1.写程序判断是否字符串A里每个字符在A中出现的次数都大于在字符串B中出现的次数。<br>注：此题我是对每个字符出现的次数分别统计，然后比较。重复的字符重复统计比较，所以效率很低。不知有什么好的改进方法？<br>2.对一个数组S，求其中满足要求的最大元素C。要求C满足等式C=A*B，其中A、B也是数组S中的元素。请用能想到的最优算法，分析时间和空间复杂度。（用语言描述算法，不用写程序）<br>注：这个题我当时做的方法在时间上要用o(n^3)，事后想出了个o(n^2logn)的方法。不知有没有更好的方法。<br>&nbsp;<br>&nbsp;<br>传说中有人说：google笔试很变态，题目希奇古怪；google题目比较基础简单。<br>终于得于一见。<br>晚上干完活才去，到的时候已经7点左右。在二教已经没有空余座位，无赖多等了20多分钟才安排了一个新的教室。<br>发题，答卷。<br>整体感觉就是比较基础，没有什么很难的题目，除最后一题目以外。<br>选择题目9个，比较基础。<br>第一题，相对比较简单，递归<br>第二题，基本是看是否对函数效率是否有概念。似乎也跟动态规划的记录法有点相似之处。<br>最后一题目回想起来实在惭愧，其实还是题目没有怎么读懂。嗨！<br>以下是科苑上，看到的解法。惭愧惭愧<br>第一和第二应该是不错的选择！<br>特别是第二种方法！</p>
<p>发信人:oasis(绿洲),信区:SISE2004702<br>标题:笔试最后一题想到的几种解法<br>发信站:BBS科苑星空站(WedOct1803:24:342006),站内<br>反正也晚了，干脆再折腾一会儿。<br>题目：n个点组成的无向图，对于任意给出的两点，判断其是否有长度为K的通路。<br>分析：无向图是允许有环存在的，也允许两点间有多条边，长度为K是指从一个点<br>移动到相邻点这样过程的次数。比如AB两点相邻，那么A-B-A-B就是长度为3的通路。<br>解法一：直接利用图论中的一个定理，邻接矩阵U的K次方后所得矩阵的(i,j)元素<br>即为原无向图中i,j两点之间长度为K的通路数量。因此复杂度只需要对U^K分析。<br>由于U^2的时间复杂度为O(n^3)，（这里使用了传统矩阵乘法，不过即使用strassan<br>方法也依然是O(n^(2+e))，其中0小技巧，不需要去依次的乘，否则的话需要K-1次矩阵乘法，可以从U^2，算出U^4，<br>依此类推，因此总的时间复杂度为O(n^3*lgK)。空间复杂度不细述O(n^2)。<br>评论一：细心的人会注意到这样的解法其实比题目的要求要强，因为题目中只是要<br>求出任意给定的两点间K通路数目，而上述做法，则是把所有的两点组合都求出来<br>了。因此还应该存在着改进的算法在O(n^2)这个时间复杂度级别。<br>解法二：这是看水木上一个网友的解法，我重写成下面这样：设所给的两点为A、B。<br>那么首先把A的所有相邻点全部放入U集合中，接着对之前放入U中的点i分别求出其相<br>邻点，并将它们放入U中（而原先的点i本身则从集合中事先去除）。这样做过K次后，<br>看队列中是否有B点。若有则表明存在着长度为K的通路。由于每次寻找邻接点的次数<br>不超过n^2，而要进行K次，因此时间复杂度为O(n^2*K)，空间复杂度为O(n)。<br>评论二：和解法一相比，从n^3*lgK变为了n^2*K，也就是n*lgK与K之间的差别，若n=k<br>的话，也就说明后者比前者快了lgK倍。<br>解法三：从A到B利用深度优先遍历，找出每一条AB间的路径，其中没有点重复经过。<br>对每一条这样的路径进行分析：<br>若长度&gt;K，该路径不可能满足；<br>若长度=K，则已满足；<br>若长度一次加一）。若无环，则看K-当前路径长度，若该值为偶数，则可以在该路径上的某两<br>个邻接点上来回的重复走从而满足要求（每来回走一次加二）。其他情况，无法满足。<br>由上得到算法的时间和空间复杂度均为O(n^2)，<br>评论三：时间复杂度很可能不是O(n^2)，因为从A到B上找出每一条AB间的简单路径，由<br>于存在着重复边和环的情况，多半就不是简单的深度遍历的O(n^2)了，具体是多少我也<br>说不清。笔试里我用的这个方法，现在感觉挺玄。。。 <br>&nbsp;</p>
<p>『2006-10-17』<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 今晚Google笔试，也是本人的&#8220;处女笔&#8221;，人山人海啊，开始Google技术总监宣讲时，有位义愤填膺的老兄，抓住提问时间，强烈指责Google搜索不了&#8220;南京大屠杀&#8221;等&#8220;不公正&#8221;现象。唉，勇气和爱国主义情感可嘉啊，只可惜为什么不弄清情况就跑来乱说话呢？<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 笔试的人数比Google预想的多出2-3倍，题目不是很难，似乎都是计算机专业的基础课。不过可惜，我不是计算机专业的，很多题目只是凭自己编程经验写的，估计希望不会太大。但是心情还不错，因为本来就没有抱太大希望，而且Google笔试尚且不是很难，就不必对其他公司笔试有太大心里压力了。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 有几道题目给出来，喜欢C的来看看：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int main()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {const char* p = "12345";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const char **q = &amp;p;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *q = "abcde";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const char *s = ++p;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p = "XYZWVU";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%c\n", *++s);<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp; 求输出结果。<br>---------------------------------------------<br>&nbsp;&nbsp; 最后一道题：<br>&nbsp;&nbsp; n个节点的无向图，判断任意两点之间是否有长度为K的通路。写出算法思路，并给出你的算法的时间和空间复杂度。<br>--------------------------------------------<br>&nbsp;&nbsp; 上面一题答案&#8220;c&#8221;，因为p是指向常量的指针，但P本身可以变化；下面一题据说是离散数学教程中的经典题型，我没有上过，只想到深度遍历的方法。<br>&nbsp;<br>google的魅力就不用词语形容了,从晚上的人气就可见一斑.准点赶到教七,却发现门口已经被人群给赌了,google的工作人员一个劲地劝大家别进去了,理由是"为了安全":).也好,不用听开复同学的唠叨.回教三的路上,一打打的人迎面而来,熟悉的,陌生的,本校的,外校的.我彷佛到了麦加,穿梭在朝圣的人流中. 但是念佛的人多,成佛的却是寥寥.晚上肯定有四位数的申请者,不过能有多少人登上幸运的快车呢?能突破个位数吗?所谓千军万马过独木桥,找工作,挺残酷!<br>　　于我,去参加笔试,更多是一种体验.选择google,权当是我对这家伟大的公司的一点敬意吧!<br>　　在软件上,我这样的水平,恐怕连菜鸟也谈不上.那么硬件呢?光学呢?我的竞争力在哪里?不能不说,对于找工作,我是有所恐惧的.现在的选择,也许不过是种逃避.<br>　　昨天,zhengzheng说他改变主意,准备工作了,一起走的兄弟,又少了一个.今天,simon说在犹豫是否调整申请的方向,因为他想以后还是进公司的.说起,5年的努力是否值得?未来也许只有上帝知道吧!<br>　　乘着脑子还清晰,先把笔试题记下:<br>　　9个选择题,2个编程,1个算法.选择题,感觉比较基础,不知里面有没有设地雷?反正没啥印象了.<br>　　编程1,打印二叉树,实现语言不限,先后也不限.<br>　　编程2,给定一个字符串数组,从中找出第一个只出现一次的字母.<br>　　算法题,给定一个整数数组,从中切出一个连续片段,保证其元素和最大.求最优算法,分析时间和空间复杂度.&nbsp; <br>&nbsp;</p>
<p>标&nbsp; 题: Google笔经<br>发信站: 饮水思源 (2006年10月11日03:06:04 星期三), 站内信件<br>开章明义，我是个废人，上来积攒rp了。<br>在宣讲会的时候，听旁边的师姐说上海只招两个职位每个职位只招一个人。<br>现在后悔只选了北京和上海的SWE了。<br>不过反正&#8230;&#8230;也不指望了。。。</p>
<p>笔试题目：9道单选+3道问答<br>时间：100分钟<br>我做的是B卷。<br>单选题：<br>1，求两个二进制数的异或值，基本上学过一点计算机的东西的人都能对的题目。。<br>2，不记得了。。也是不需要思考的题目。。<br>3，大概是如下的函数：<br>int someFunc(int x){<br>&nbsp;&nbsp;&nbsp; if (x == 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return x + someFunc(x - 1);<br>}<br>问这个计算的是什么。。。<br>4，不记得了。。不需要思考吧。。<br>5，不记得了。。不需要思考吧。。<br>6，参见2，4，5。。<br>7，似乎需要思考一下。。<br>8，问链表结构和数组相比的优势不包括哪项，<br>包括：<br>插入的时间<br>删除的时间<br>存储空间<br>剩下两个不记得了。。<br>9，如下函数：<br>T(x) = 1 (x &lt;= 1)<br>T(n) = 25 T(n/5) + n^2<br>问T(n)随n的增长。<br>选项大概是这样的：<br>O(n^2)，O(n^2logn)等等的。。<br>&nbsp;<br>问答：<br>1，写两个N*N的矩阵的乘法，给出了C的格式，你可以选择你喜欢的语言去写。。<br>int* multi(int* a1, int* a2, int N){<br>}<br>2，寻找一个单向链表的中项，如果存在两个则返回前一个。给出了C的格式，同样你可<br>以选择。。。。<br>struct {<br>&nbsp;&nbsp;&nbsp; Node* next;<br>&nbsp;&nbsp;&nbsp; int value;<br>} Node;<br>Node* someFunc(Node* head){<br>}<br>3，给一个长度为n的整数数组，只允许用乘法不允许用除法，计算任意(n-1)个数的组合<br>乘积中最大的一组。。。写出算法的时空复杂度。<br>ps：怀疑这道题目出错啦。。虽然我也做错了。。。。。。<br>&nbsp;<br>&nbsp;<br>一些补充：<br>1，问答的第一题是google上学期 intern的大题原题；<br>2，google很喜欢考链表，无论intern的面试以及两次的笔试都有这样的题目；<br>3，google一般大题第三道都是写算法的时空复杂度；<br>4，选择题基本上偏简单，但是要做得准确率高似乎并不那么容易；<br>5，根据传言，小道消息，人云亦云以及以讹传讹，google的高速审卷政策来源于审卷时<br>以选择题为主，如果你全对啦，那么恭喜你pass啦；如果你错了好几道，那么下次努力<br>吧，如果还有下次。。。大题基本是做参考的。。。<br>6，选择题很多记不清了，因为一遍做下来的，回去随便扫了两眼。。。加上过了这几个<br>小时，记不得了。希望大家补充修正以及修改。。。<br>7，google会在11号开始3天内发面试通知，据小道消息等等，有四轮面试。bless大家~~<br>&nbsp;</p>
<p>google brainy test/exam 就是流传甚广的传说中的google 的21道 GLAT 考试了。<br>　　10月底，Google在美国《麻省技术评论》、《LinuxJournal》、《Mensa》、《今日物理》等几本专业杂志上，刊登了一份"Google实验室能力倾向测试"。<br>　　试卷开头，蛊惑地写着"试试看！把答案寄回Google，你有希望去Google总部参观，并成为我们其中一员"。<br>1. Solve this cryptic equation, realizing of<br>course that values for M and E could be<br>interchanged. No leading zeros are allowed.<br>WWWDOT - GOOGLE = DOTCOM<br>2. Write a haiku describing possible methods<br>for predicting search traffic seasonality.<br>3.<br>1<br>1 1<br>2 1<br>1 2 1 1<br>1 1 1 2 2 1<br>What is the next line?<br>4. You are in a maze of twisty little passages,<br>all alike. There is a dusty laptop here with a<br>weak wireless connection. There are dull,<br>lifeless gnomes strolling about. What dost<br>thou do?<br>A) Wander aimlessly, bumping into<br>obstacles until you are eaten by a grue.<br>B) Use the laptop as a digging device to<br>tunnel to the next level.<br>C) Play MPoRPG until the battery dies<br>along with your hopes.<br>D) Use the computer to map the nodes<br>of the maze and discover an exit path.<br>E) Email your resume to Google, tell the<br>lead gnome you quit and find yourself<br>in whole different world.<br>5. What&#8217;s broken with Unix?<br>How would you fix it?<br>6. On your first day at Google, you discover<br>that your cubicle mate wrote the textbook<br>you used as a primary resource in your first<br>year of graduate school. Do you:<br>A) Fawn obsequiously and ask if you<br>can have an autograph.<br>B) Sit perfectly still and use only soft<br>keystrokes to avoid disturbing her<br>concentration.<br>C) Leave her daily offerings of granola<br>and English toffee from the food bins.<br>D) Quote your favorite formula from the<br>textbook and explain how it&#8217;s now<br>your mantra.<br>E) Show her how example 17b could<br>have been solved with 34 fewer lines<br>of code.<br>7. Which of the following expresses Google□<br>over-arching philosophy?<br>A) "I&#8217;m feeling lucky"<br>B) "Don&#8217;t be evil"<br>C) "Oh, I already fixed that"<br>D) "You should never be more than<br>50 feet from food"<br>E) All of the above<br>8. How many different ways can you color an<br>icosahedron with one of three colors on<br>each face?<br>What colors would you choose?<br>9. This space left intentionally blank. Please fill it<br>with something that improves upon emptiness.<br>10.On an infinite, two-dimensional, rectangular<br>lattice of 1-ohm resistors, what is the<br>resistance between two nodes that are a<br>knight&#8217;s move away?<br>11.It&#8217;s 2 PM on a sunny Sunday afternoon in the<br>Bay Area. You&#8217;re minutes from the Pacific<br>Ocean, redwood forest hiking trails and world<br>class cultural attractions. What do you do?<br>12.In your opinion, what is the most beautiful<br>math equation ever derived?<br>13. Which of the following is NOT an actual<br>interest group formed by Google employees?<br>A. Women&#8217;s basketball<br>B. Buffy fans<br>C. Cricketeers<br>D. Nobel winners<br>E. Wine club<br>14.What will be the next great improvement in<br>search technology?<br>15.What is the optimal size of a project team,<br>above which additional members do not<br>contribute productivity equivalent to the<br>percentage increase in the staff size?<br>A) 1<br>B) 3<br>C) 5<br>D) 11<br>E) 24<br>16.Given a ABC, how would you use only<br>a compass and straight edge to find a point P<br>such that s ABP, ACP and BCP have<br>equal perimeters? (Assume that ABC is<br>constructed so that a solution does exist.)<br>17.Consider a function which, for a given whole<br>number n, returns the number of ones required<br>when writing out all numbers between 0 and n.<br>For example, f(13)=6. Notice that f(1)=1. What<br>is the next largest n such that f(n)=n?<br>18.What&#8217;s the coolest hack you&#8217;ve ever written?<br>19.&#8217;Tis known in refined company, that choosing<br>K things out of N can be done in ways as<br>many as choosing N minus K from N: I pick K,<br>you the remaining.<br>Find though a cooler bijection, where you show<br>a knack uncanny, of your choices contain<br>all K of mine. Oh, for pedantry: let K be no more<br>than half N.<br>20.What number comes next in the sequence:<br>10, 9, 60, 90, 70, 66,?<br>A)96<br>B) 1000000000000000000000000000000000<br>0000000000000000000000000000000000<br>000000000000000000000000000000000<br>C) Either of the above<br>D) None of the above<br>21.In 29 words or fewer, describe what you<br>would strive to accomplish if you worked<br>at Google Labs.<br>&nbsp;<br>&nbsp;<br>Google惯用&#8220;整蛊题&#8221; <br>　　Google上一轮招聘，今年夏天刚结束。 <br>　　用的也是一道&#8220;科学麻瓜&#8221;看不懂的&#8220;整蛊题&#8221;，而且，堂而皇之挂在硅谷各大地铁站上。9月底，3块15米长的米色广告牌上，简简单单刷着&#8220;（在&#8216;e&#8217;的数列中所能找到的第一个十位数质数）.com&#8221;，没有公司名也没有任何广告词。 <br>　　花了几秒钟，路人才明白，这是一道数学题。自然常数e（2.718281828&#8230;&#8230;）的第一个十位数质数，是目标网站的名字。 <br>　　好奇分子忍不住用Google搜索起答案来，压根儿不晓得这就是Google出的&#8220;硬骨头&#8221;考题。 <br>　　不少人后来在规定时间内，登录上了<a href="http://www.7427466391.com/">www.7427466391.com</a>。然而，那不是梦寐以求的终点站，Google恶作剧似的，为&#8220;高手&#8221;们在半山腰设了个休息的小凉亭。 <br>　　<a href="http://www.7427466391.com/">www.7427466391.com</a>里，贴出一条更令人头疼的数学问题，答出这个问题，能得到进入下一个网页的密码。 <br>　　跑完数学&#8220;马拉松&#8221;，7500个&#8220;幸存者&#8221;走入Google实验室网页，成功投出简历。最后，Google只要了50个人。&#8220;光以广告而论，Google也算得上高段！&#8221; <br>　　波士顿一家广告公司的高级副总裁弗里茨&#183;库恩分析，&#8220;目标人群看到广告后会想，&#8216;这是我的语言，那是冲着我来的&#8217;；对其他人而言，广告也使Google的形象大大提升。他们可能会想，&#8216;我是得不到这份工作的了。不过，在那儿工作的人真聪明&#8217;。&#8221; <br>　　Google测试考的就是脑筋 <br>　　&#183;试着证明WWWDOT-GOOGLE=DOTCOM&#183;用俳句（一种日本短诗，每句有一个与季节有关的词）来描述各种模型，借此预测网络搜索流量的季节性变化。 <br>　　&#183;你落入一个迷宫，回旋不断的走廊。手里有一台堆满灰尘的手提电脑，可以无线上网。周围，许多无生命的侏儒徘徊走动。这种情况下，你会如何做？ <br>　　A)无目的地徘徊，不停走入死胡同，然后被迷宫里面的妖怪吃掉。 <br>　　B)用手提电脑当铲子，打穿地板直接进入游戏下一关。 <br>　　C)玩网络游戏《魔法奇兵》，直到电池耗尽。 <br>　　D)利用计算机，找到迷宫的节点，发现准确出路。 <br>　　E)把你的简历寄给Google，告诉迷宫里领头的妖怪，你要退出游戏。然后，发现你回到了现实世界。 <br>　　&#183;Unix有什么问题？你会如何补救它？ <br>　　&#183;你在Google工作的第一天，发现你同寝室的室友，曾写过一本书。你研究生一年级时，这本书是你最重要的参考资料。你会：A)求他帮你签个名。B)不改坐姿，却放轻打字声音，尽量避免影响他。 <br>　　C)把你每天吃的麦片和咖啡，留给他吃。 <br>　　D)引用他那本书中间，你最喜欢的程式，告诉他这则方程给了你多少启发。 <br>　　E)让他看看，你可以用不到34句语句，完成一个高难度程序。 <br>　　&#183;以下哪个最好地表达了Google的企业文化？ <br>　　A)&#8220;我感觉挺幸运&#8221; <br>　　B)&#8220;别干坏事&#8221; <br>　　C)&#8220;哦，我已经完成了任务&#8221; <br>　　D)&#8220;你身边10米以内，必定能找到食物&#8221; <br>　　E)以上皆是&#183;用1欧姆的电阻，组成无限大的放行点阵，问&#8220;象棋跳马步&#8221;（&#8220;日&#8221;字对角点）两点之间的电阻是多少？ <br>　　&#183;下午2点，旧金山著名的湾区。你可以选择去阳光海岸、国家公园的红杉林里徒步旅行，或者参观城市 <br>里的文化景观。你会怎么做？ <br>　　&#183;搜索技术的下一个革命性突破是什么？ <br>　　&#183;一个技术研究小组的最优化人员组合是几个人？一旦超过这个数字，每增加一个研究员，平均生产力就会相应下降：A)1B)3C)5D)11E)24&#183;三角形ABC，用圆规和尺，找出点P，保证三角形ABP、ACP和BCP周长相等。 <br>　　&#183;你写过最酷的程序是什么？ <br>　　&#183;找出此数列的下一个:10,9,60,90,70,66?A)96B)10的100次方C)A或者BD)以上皆否&#183;用少于29个词，描述你能带给Google实验室的贡献。 <br>&nbsp;<br>&nbsp;<br>今年10月底，Google在美国《麻省技术评论》、《LinuxJournal》、《Mensa<br>》、《今日物理》等几本专业杂志上刊登了一份&#8220;Google实验室能力倾向测试&#8221;的<br>试卷，开头蛊惑地写着&#8220;试试看！把答案寄回Google，你有希望去Google总部参观<br>，并成为我们其中一员&#8221;。有兴趣的人可以做完了邮寄给Google公司，也许会得到<br>一个工作机会呢。<br>　　1、解答下面的隐藏等式，其中的M和E的值可以互换，但不允许第一位是0：<br>　　WWWDOT - GOOGLE = DOTCOM<br>　　2、用一个俳句(一种日本短诗，每句有一个与季节有关的词)来建立模型，借<br>此预测网络搜索流量的季节性变化；<br>　　3、<br>　　1<br>　　1 1<br>　　2 1<br>　　1 2 1 1<br>　　1 1 1 2 2 1<br>　　下一行是什么？<br>　　4、你正处于一个全部由崎岖小路构成的迷宫里，手里有一个满是灰尘的笔记<br>本，可以无线上网，但是信号很弱。与此同时，一些阴森可怕、毫无生气的妖怪在<br>你身边游荡。你会怎么做呢？<br>　　(1)毫无目的的四处游荡，到处碰壁，直到被迷宫里的妖怪吃掉。<br>　　(2)用笔记本作为挖掘工具，打穿地面直接进入下一关。<br>　　(3)玩网络游戏《魔法骑兵》，直至电池耗尽，你也心灰意冷。<br>　　(4)使用笔记本画出迷宫的节点地图，找到出路。<br>　　(5)发送简历给Google，告诉主管妖怪你选择退出，随后你就回到现实世界。<br>　　5、Unix有何缺陷？你准备如何补救？<br>　　6、在Google工作的第一天，你发现身边的同事竟然是研究生一年级课本的作<br>者，你会：<br>　　(1)主动示好并索取签名。<br>　　(2)不改变坐姿，但放轻打字声音，避免影响她的工作和思考。<br>　　(3)把你每天的麦片和咖啡都留给她享用。<br>　　(4)在她所写的书中找到你最喜欢的内容，并告诉她这些内容已经成为你的座<br>右铭。<br>　　7、下列哪句话最贴切的表达了Google的企业文化？<br>　　(1)我感到很幸运。<br>　　(2)不要干坏事。<br>　　(3)哦，我已经解决了那个问题。<br>　　(4)你身边50英寸之内，必定能找到食物。<br>　　(5)以上皆是。<br>　　8、用3种颜色为20面体上色，每个面一种颜色，有多少种组合？你会选择哪些<br>颜色？<br>　　9、下面是故意留出的空白，请将其填满，使之看起来不那么空。<br>　　10、用1欧姆的电阻组成无限大的两维矩阵，&#8220;象棋跳马步&#8221;(&#8220;日&#8221;字对角点<br>)两点之间的电阻是多少？<br>　　11、现在是星期日下午2点，你正在旧金山著名的湾区。你可以选择去国家公<br>园的红杉林里徒步旅行，或者参观城市里的文化景观。你会怎么做？<br>　　12、你认为最美的数学等式是什么？<br>　　13、下列哪个团体没有在Google员工中形成？<br>　　(1)女子篮球<br>　　(2)淡黄色爱好者<br>　　(3)Cricketeers<br>　　(4)诺贝尔奖获得者<br>　　(5)葡萄酒俱乐部<br>　　14、搜索技术的下一个革命性突破是什么？<br>　　15、一个项目组由多少人构成才能达到最优规模？也就是说，一旦超过这一数<br>字，每增加一个成员项目组的平均生产力就会相应下降。<br>　　(1)1个<br>　　(2)3个<br>　　(3)5个<br>　　(4)11个<br>　　(5)24个<br>　　16、给你一个三角形ABC，请用圆规和尺找出点P，保证三角形ABP、ACP和BCP<br>周长相等。<br>　　17、有这样一个函数，对于任意整数n，都能返回写出0到n之间出现&#8220;1&#8221;的个<br>数。例如，f（13）=6。请注意f（1）=1，那么下一个能实现f（n）=n的最大数字<br>是什么？<br>　　18、你编写的最酷的黑客程序是什么？<br>　　19、在下面的数列中，下一个数字是多少：10, 9, 60, 90, 70, 66,?<br>　　(1)96<br>　　(2)10的100次方<br>　　(3)以上皆是<br>　　(4)以上皆不是<br>　　20、用少于29个词，描述你能带给Google实验室带来的贡献。(天外)<br>--<br>&#8220;微软是个公平的公司，这里几乎没有特权。盖茨只是这两年才有了自己的一个停车位。<br>以前他来晚了没地儿，就得自己到处去找停车位。&#8221;<br>&#8220;微软非常强调员工的动手能力。在做新产品发布时，盖茨都能自己动手做演示。他总<br>是在和工程师作搭档，对自己的产品很熟悉，这样，任何人都糊弄不了他。&#8221; <br>&nbsp;</p>
<p>1.单项选择题<br>1.&nbsp; 下面一段代码的输出是[&nbsp; ]<br>void fn( int* b){<br>&nbsp;&nbsp;&nbsp; (*b)++;<br>}<br>int main(){<br>&nbsp;&nbsp;&nbsp; int a=7;<br>&nbsp;&nbsp;&nbsp; fn(&amp;a);<br>cout&lt;&lt;a;<br>return 0;<br>}<br>A.0&nbsp;&nbsp;&nbsp;&nbsp; B.7&nbsp;&nbsp;&nbsp; C.8&nbsp;&nbsp;&nbsp; D.undefined<br>2.&nbsp; 定义int i,j,*p=&amp;i; 那么下面哪条语句可以完成i=j的赋值[&nbsp; ]<br>A.i=*p;&nbsp;&nbsp;&nbsp;&nbsp; B. *p=*&amp;j;&nbsp;&nbsp;&nbsp; C.i=&amp;j;&nbsp;&nbsp;&nbsp; D.I=**p;<br>3.&nbsp; 用二叉搜索树和哈希表存储相同的数据集,对于以下何种操作,二叉搜索树比哈希表</p>
<p>速度更快?[&nbsp; ]<br>A.检索&nbsp;&nbsp;&nbsp; B. 插入&nbsp;&nbsp;&nbsp; C.删除&nbsp;&nbsp;&nbsp; D.更新&nbsp;&nbsp;&nbsp; E.排序<br>4.&nbsp; 包含N个几点和M条边的有向带权图G, 边的权为正, 以下操作中不可以在O(N+M)<br>的时间复杂度内完成的操作是:[&nbsp; ]<br>A.&nbsp; 求结点s到结点t之间的最短距离<br>B.&nbsp; 求距离结点s最近的结点<br>C.&nbsp; 已知起始结点, 对图G中的结点进行拓扑排序<br>D.&nbsp; 求图G的最大强连通子图<br>5.&nbsp; 有如下递归函数f(n),其时间复杂度为[&nbsp; ]<br>int f(int n){<br>&nbsp;&nbsp;&nbsp; if(n==0)<br>&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>&nbsp;&nbsp;&nbsp; if(n==1)<br>&nbsp;&nbsp;&nbsp;&nbsp; return 1;<br>&nbsp;&nbsp;&nbsp; return ( 5*f(n-1) - 6*f(n-2));<br>}<br>A.O(n)&nbsp;&nbsp;&nbsp;&nbsp; B. O(n^2)&nbsp;&nbsp;&nbsp; C. O(n^3)&nbsp;&nbsp;&nbsp; D. O(2^n)<br>6.&nbsp; 下面所述步骤中,哪一个不是创建经常所必需有的[&nbsp; ]<br>A.由调度程序为进程分配CPU&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B.建立一个进程控制块<br>C.为进程分配内存&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; D.将进程控制块链入就绪队列<br>7.&nbsp; 在多进程的系统中,为了保证公区变量的完整性,各进程应互斥进入临界区。所谓临</p>
<p>界区是[&nbsp; ]<br>A.一个缓冲区&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B.一个数据区&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C.一个同步机构&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; D.一段程序<br>8.&nbsp; 能产生满足如下条件语言的正则表达式是：1.每一个a后至少紧跟两个c; 2.每一个b</p>
<p>后至少紧跟一个c [&nbsp; ]<br>A.(acc|bc|c)*&nbsp;&nbsp; B.(acc|bc)* C.(ac|bc)*&nbsp; D.不是正则语言<br>9.&nbsp; 以下哪项不是RPC（远程过程调用）的特点[&nbsp; ]<br>A.速度快&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B.降低系统耦合度&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C.可以实现异构系统间的协作<br>10. 有三个桶，容量分别是3升，5升，7升，你只能进行下面的操作：<br>把一个桶中所有的水倒掉；<br>把一个桶A中的水倒入桶B，直到桶A空了或者桶B满了；<br>假设一开始容量为3升和5升的桶是满的，7升的桶是空的，希望通过一系列操作使3个桶</p>
<p>中任意一个中正好有4升水，那么至少需要[&nbsp; ]次操作。<br>A.3&nbsp;&nbsp;&nbsp;&nbsp; B.5&nbsp;&nbsp;&nbsp;&nbsp; C.7&nbsp;&nbsp;&nbsp;&nbsp; D.不可能<br>2.&nbsp; 程序设计与算法<br>2.1 实现如下编码算法，对于重复2-9次数的字符，用两个数字表示，即NX（其中N为重</p>
<p>复的次数，X为重复的字符，下同），超过九个则先输出9X，然后处理剩下的字符。对于</p>
<p>连续的不重复的字符，则两边加1来封字符串。如果被封的字符串其中有数字为1，则用1</p>
<p>来转义。&nbsp;&nbsp;&nbsp; 示例： AAAAAABCCCC -&gt; 6A1B14C,&nbsp; 12344 -&gt; 11123124。。。（下面的框</p>
<p>架是用C++语言写的。你可以用你熟悉的语言。）<br>void encode (const char* text, char* dest)<br>text 为需要编码的字符串，dest表示编码输出的目标空间，而空间足够大<br>2.2给定一颗有n个结点的二叉树。求它的所有结点数为m的连通子图数目。m&lt;=n分析你的</p>
<p>算法的时间复杂度，解释算法即可，不必写代码。<br>&nbsp;<br>&nbsp;<br>用:&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp; 假设有这样一种字符串，它们的长度不大于&nbsp;&nbsp; 26&nbsp;&nbsp; ，而且若一个这样的字符串其长度为&nbsp;&nbsp; m&nbsp;&nbsp; ，则这个字符串必定由&nbsp;&nbsp; a,&nbsp;&nbsp; b,&nbsp;&nbsp; c&nbsp;&nbsp; ...&nbsp;&nbsp; z&nbsp;&nbsp; 中的前&nbsp;&nbsp; m&nbsp;&nbsp; 个字母构成，同时我们保证每个字母出现且仅出现一次。比方说某个字符串长度为&nbsp;&nbsp; 5&nbsp;&nbsp; ，那么它一定是由&nbsp;&nbsp; a,&nbsp;&nbsp; b,&nbsp;&nbsp; c,&nbsp;&nbsp; d,&nbsp;&nbsp; e&nbsp;&nbsp; 这&nbsp;&nbsp; 5&nbsp;&nbsp; 个字母构成，不会多一个也不会少一个。嗯嗯，这样一来，一旦长度确定，这个字符串中有哪些字母也就确定了，唯一的区别就是这些字母的前后顺序而已。&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp; 现在我们用一个由大写字母&nbsp;&nbsp; A&nbsp;&nbsp; 和&nbsp;&nbsp; B&nbsp;&nbsp; 构成的序列来描述这类字符串里各个字母的前后顺序：&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp; 如果字母&nbsp;&nbsp; b&nbsp;&nbsp; 在字母&nbsp;&nbsp; a&nbsp;&nbsp; 的后面，那么序列的第一个字母就是&nbsp;&nbsp; A&nbsp;&nbsp; （After），否则序列的第一个字母就是&nbsp;&nbsp; B&nbsp;&nbsp; （Before）；&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp; 如果字母&nbsp;&nbsp; c&nbsp;&nbsp; 在字母&nbsp;&nbsp; b&nbsp;&nbsp; 的后面，那么序列的第二个字母就是&nbsp;&nbsp; A&nbsp;&nbsp; ，否则就是&nbsp;&nbsp; B；&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp; 如果字母&nbsp;&nbsp; d&nbsp;&nbsp; 在字母&nbsp;&nbsp; c&nbsp;&nbsp; 的后面，那么&nbsp;&nbsp; &#8230;&#8230;&nbsp;&nbsp; 不用多说了吧？直到这个字符串的结束。&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp; 这规则甚是简单，不过有个问题就是同一个&nbsp;&nbsp; AB&nbsp;&nbsp; 序列，可能有多个字符串都与之相符，比方说序列&#8220;ABA&#8221;，就有&#8220;acdb&#8221;、&#8220;cadb&#8221;等等好几种可能性。说的专业一点，这一个序列实际上对应了一个字符串集合。那么现在问题来了：给你一个这样的&nbsp;&nbsp; AB&nbsp;&nbsp; 序列，问你究竟有多少个不同的字符串能够与之相符？或者说这个序列对应的字符串集合有多大？注意，只要求个数，不要求枚举所有的字符串。&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp; 嘿嘿，这就是你要解决的问题了。如果不嫌慢的话大可以穷举，不过这种解法拿出来那是显然不好意思和人打招呼的。事实上，如果设&nbsp;&nbsp; AB&nbsp;&nbsp; 序列的长度为&nbsp;&nbsp; n&nbsp;&nbsp; ，那么这个问题是可以做到&nbsp;&nbsp; O(n^3)&nbsp;&nbsp; 的。&nbsp; <br>&nbsp;</p>
<p>1、有两根不均匀分布的香，香烧完的时间是一个小时，你能用什么方法来确定一段15分钟的时间？<br>答：2根香同时点燃，第一根两头都点燃，第二根只点一头， 第一根点完的时候是半个小时，接着把第二根两头都点燃，第二根点完的时候就是15分钟。</p>
<p>２、一个经理有三个女儿，三个女儿的年龄加起来等于13，三个女儿的年龄乘起来等于经理自己的年龄，有一个下属已知道经理的年龄，但仍不能确定经理三个女儿的年龄，这时经理说只有一个女儿的头发是黑的，然后这个下属就知道了经理三个女儿的年龄。请问三个女儿的年龄分别是多少？为什么？</p>
<p>答：2，2，9， 1岁不可能</p>
<p>3、有三个人去住旅馆，住三间房，每一间房$10元，于是他们一共付给老板$30，第二天，老板觉得三间房只需要$25元就够了于是叫小弟退回$5给三位客人，谁知小弟贪心,只退回每人$1，自己偷偷拿了$2，这样一来便等于那三位客人每人各花了九元，于是三个人一共花了$27，再加上小弟独吞了不$2，总共是$29。可是当初他们三个人一共付出$30那么还有$1呢？<br>答：没错，三个人付了27块，老板拿了25块，小弟拿了2块<br>４、有两位盲人，他们都各自买了两对黑袜和两对白袜，八对袜了的布质、大小完全相同，而每对袜了都有一张商标纸连着。两位盲人不小心将八对袜了混在一起。 他们每人怎样才能取回黑袜和白袜各两对呢？</p>
<p>答：不知道，还要仔细想想<br>５、有一辆火车以每小时15公里的速度离开洛杉矶直奔纽约，另一辆火车以每小时20公里的速度从纽约开往洛杉矶。如果有一只鸟，以30公里每小时的速度和两辆火车同时启动，从洛杉矶出发，碰到另一辆车后返回，依次在两辆火车来回飞行，直到两辆火车相遇，请问，这只小鸟飞行了多长距离？</p>
<p>答：记好两车相遇时间，就是鸟飞行时间，乘以其飞行速度就得到飞行距离。</p>
<p>６、你有两个罐子，50个红色弹球，50个蓝色弹球，随机选出一个罐子，随机选取出一个弹球放入罐子，怎么给红色弹球最大的选中机会？在你的计划中，得到红球的准确几率是多少？</p>
<p>答：不知道，还要仔细想想</p>
<p>７、你有四个装药丸的罐子，每个药丸都有一定的重量，被污染的药丸是没被污染的重量＋1.只称量一次，如何判断哪个罐子的药被污染了？<br>答：不知道，还要仔细想想<br>８、你有一桶果冻，其中有黄色，绿色，红色三种，闭上眼睛，抓取两个同种颜色的果冻。抓取多少个就可以确定你肯定有两个同一颜色的果冻？<br>答：4</p>
<p>９、对一批编号为1～100，全部开关朝上(开)的灯进行以下*作：凡是1的倍数反方向拨一次开关；2的倍数反方向又拨一次开关；3的倍数反方向又拨一次开关&#8230;&#8230;问：最后为关熄状态的灯的编号。</p>
<p>答：不知道，还要仔细想想</p>
<p>１０、想象你在镜子前，请问，为什么镜子中的影像可以颠倒左右，却不能颠倒上下？</p>
<p>答：人的眼睛是左右对称的<br>１１、一群人开舞会，每人头上都戴着一顶帽子。帽子只有黑白两种，黑的至少有一顶。每个人都能看到其它人帽子的颜色，却看不到自己的。主持人先让大家看看别人头上戴的是什幺帽子，然后关灯，如果有人认为自己戴的是黑帽子，就打自己一个耳光。第一次关灯，没有声音。于是再开灯，大家再看一遍，关灯时仍然鸦雀无声。一直到第三次关灯，才有劈劈啪啪打耳光的声音响起。问有多少人戴着黑帽子？<br>答：3&nbsp; <br>&nbsp;<br>&nbsp;</p>
<p>一、单选<br>1、80x86中，十进制数-3用16位二进制数表示为？<br>2、假定符号-、*、$分别代表减法、乘法和指数运算，且<br>1)三个运算符优先级顺序是：-最高，*其次，$最低；<br>2)运算符运算时为左结合。请计算3-2*4$1*2$3的值：<br>(A)4096，(B)-61，(C)64，(D)-80，(E)512<br>3、下列伪代码中，参数是引用传递，结果是？<br>calc(double p, double q, double r){q=q-1.0;r=r+p}<br>main(){<br>　　double a = 2.5, b = 9.0;<br>　　calc(b-a, a, a);<br>　　print(a);<br>}<br>(A)1.5 (B)2.5 (C)10.5 (D)8 (E)6.5<br>4、求输出结果：<br>int foo(int x, int y){<br>　　if(x &lt;=0 || y &lt;= 0) return 1;<br>　　return 3 * foo(x - 1, y / 2);<br>}<br>printf("%d\n", foo(3, 5));<br>(A)81 (B)27 (C)9 (D)3 (E)1<br>5、下列哪个数据结构在优先队列中被最广泛使用？<br>(A)堆 (B)数组 (C)双向链表 (D)图 (E)向量<br>6、以下算法描述了一个在n国元素的双向链表中找到第k个元素的方法（k &gt;= 1且k &lt;= n）：<br>如果k &lt;= n - k，从链表开始往前进k-1个元素。<br>否则，从终点出发，往回走n - k个元素。<br>这个算法的时间代价是？<br>(A)&#952;(nlogn) (B)&#952;(max{k, n - k}) (C)&#952;(k + (n - k))<br>(D)&#952;(max{k, k - n}) (E)&#952;(min{k, n - k})<br>7、有一个由10个顶点组成的图，每个顶点有6个度，那么这个图有几条边？<br>(A)60 (B)30 (C)20 (D)80 (E)90<br>8、正则表达式L = x*(x|yx+)。下列哪个字符串不符合L<br>(A)x (B)xyxyx (C)xyx (D)yxx (E)yx<br>9、为读取一块数据而准备磁盘驱动器的总时间包括<br>(A)等待时间 (B)寻道时间 (C)传输时间 (D)等待时间加寻道时间<br>(E)等待时间加寻道时间加传输时间<br>二、算法<br>1、打印出一个二叉树的内容。<br>2、在一个字符串中找到第一个只出现一次的字符。如abaccdeff，输出b。<br>3、给定一个长度为N的整数数组（元素有正有负），求所有元素之和，最大的一个子数组。分析算法时空复杂度。不必写代码。</p>
<p>附上动态规划做法的答案:<br>最大子序列<br>问题：<br>给定一整数序列A1， A2，... An （可能有负数），求A1~An的一个子序列Ai~Aj，使得Ai到Aj的和最大<br>例如：整数序列-2, 11, -4, 13, -5, 2, -5, -3, 12, -9的最大子序列的和为21。对于这个问题，最简单也是最容易想到的那就是穷举所有子序列的方法。利用三重循环，依次求出所有子序列的和然后取最大的那个。当然算法复杂度会达到O (n^3)。显然这种方法不是最优的，下面给出一个算法复杂度为O(n)的线性算法实现，算法的来源于Programming Pearls一书。在给出线性算法之前，先来看一个对穷举算法进行优化的算法，它的算法复杂度为O(n^2)。其实这个算法只是对对穷举算法稍微做了一些修改：其实子序列的和我们并不需要每次都重新计算一遍。假设Sum(i, j)是A ... A[j]的和，那么Sum(i, j+1) = Sum(i, j) + A[j+1]。利用这一个递推，我们就可以得到下面这个算法：<br>int max_sub(int a[],int size)<br>{<br>　　int i,j,v,max=a[0];<br>　　for(i=0;i&lt;size;i++)<br>　　{<br>　　　　v=0;<br>　　　　for(j=i;j&lt;size;j++)<br>　　　　{<br>　　　　　　v=v+a[j];//Sum(i, j+1) = Sum(i, j) + A[j+1]<br>　　　　　　　　if(v&gt;max)<br>　　　　　　　　　max=v;<br>　　　　}<br>　　}<br>　　return max;<br>}<br>那怎样才能达到线性复杂度呢？这里运用动态规划的思想。先看一下源代码实现：<br>int max_sub2(int a[], int size)<br>{<br>　　int i,max=0,temp_sum=0;<br>　　for(i=0;i&lt;size;i++)<br>　　{<br>　　　　　　temp_sum+=a;<br>　　　　　　if(temp_sum&gt;max)<br>　　　　　　　　max=temp_sum;<br>　　　　　　else if(temp_sum&lt;0)<br>　　　　　　　　temp_sum=0;<br>　　}<br>　　return max;<br>}<br>在这一遍扫描数组当中，从左到右记录当前子序列的和temp_sum，若这个和不断增加，那么最大子序列的和max也不断增加(不断更新 max)。如果往前扫描中遇到负数，那么当前子序列的和将会减小。此时temp_sum 将会小于max，当然max也就不更新。如果temp_sum降到0时，说明前面已经扫描的那一段就可以抛弃了，这时将temp_sum置为0。然后， temp_sum将从后面开始将这个子段进行分析，若有比当前max大的子段，继续更新max。这样一趟扫描结果也就出来了。&nbsp; <br>&nbsp;<br>&nbsp;</p>
<p>Google笔试是没有门槛的。这样说是因为Google根本没有限制笔试的人数，开了N个教室，让N多人参加&#8230;&#8230;不过笔试本身却有门槛，看了题目就知道。<br>　　本来想上午写写的，但是，嗯，出于攒人品的目的，还是等到现在才写——现在，面试通知已经发过，很显然我又被无视了&#8230;&#8230;OK，那也不错，我也没怎么准备这些东西呢，倒不是说我不重视，而是事情太多&#8230;&#8230;唔，多少算是一种经验了。<br>　　回来说说昨天的笔试。题目的量并不大，除了几个单选题，剩下就是三个编程或算法题。单选就不说了，考得比较基础，涉及C语言常识、数据结构、文法、操作系统，主要说说大题。<br>　　大题虽然题型不一，但都有一个重要特点：考递归。精确点说，我每一题都用到了递归。<br>　　第一个的题目（嗯，记的不是很完整）：<br>在一棵（排序？）二叉树中搜索指定值，数据结构定义为（唉唉，数据结构的具体名字都不记得了，my god）：<br>struct Node<br>{<br>&nbsp;&nbsp;&nbsp; Node * lnext;<br>&nbsp;&nbsp;&nbsp; Node * rnext;<br>&nbsp;&nbsp;&nbsp; int value;<br>};<br>函数定义为（情况同上，啥都记不清了）：<br>Node * search(Node * root, int value)<br>{<br>}<br>实现这个search函数。<br>用递归，经典的树的遍历，pass先。<br>第二个的题目：<br>计算Tribonaci队列（嗯，九成九记错了那个单词&#8230;&#8230;），规则是T(n) = T(n - 1) + T(n - 2) + T(n -3)，其中T(0) = T(1) = 1，T(2) = 2。<br>函数定义：<br>int Tribonaci(int n) {<br>}<br>备注，不考虑证整数溢出，尽可能优化算法。<br>　　这一题我一看就知道要考什么，很显然的递归定义，但也是很显然的，这里所谓的优化是指不要重复计算。<br>　　简单的说，在计算T(n)的时候要用到T(n - 1)、T(n - 2)和T(n - 3)的结果，在计算T(n - 1)的时候也要用到T(n - 2)和T(n - 3)的结果，所以在各项计算的时候必须把以前计算的结果记录下来，去掉重复计算。这里用到的一点小技巧就是要新写一个函数用来做这种事情，嗯，看看我写的代码吧！<br>&nbsp;&nbsp;&nbsp; /**<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Get the value of T(n - 1), and retrieve the result of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T(n - 2) and T(n - 3).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @param[in] n The n in T(n).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @param[out] mid Value of T(n - 2).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @param[out] right Value of T(n - 3).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @return Value of T(n - 1).<br>&nbsp;&nbsp;&nbsp;&nbsp; */<br>&nbsp;&nbsp;&nbsp; int find_trib(int n, int &amp; mid, int &amp; right)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (3 == n)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mid = 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; right = 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int temp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mid = find_trib(n - 1, right, temp);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return mid + right + temp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; /**<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Find value of T(n).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @param[in] The n in T(n).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @return Value of T(n).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @note T(n) = T(n - 1) + T(n - 2) + T(n - 3) (n &gt; 2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T(0) = T(1) = 1, T(2) = 2.<br>&nbsp;&nbsp;&nbsp;&nbsp; */<br>&nbsp;&nbsp;&nbsp; int tribonaci(int n)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (n &lt; 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Undefined feature.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (0 == n || 1 == n)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (2 == n)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int mid, right;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int left = find_trib(n, mid, right);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return left + mid + right;<br>&nbsp;&nbsp;&nbsp; }<br>　　啊啊，对了，答卷的时候我可没心情写注释&#8230;&#8230;刚才到VC.Net 2003上测试了一下，貌似没有啥问题。唉，看来我多少还是懂一点算法的&#8230;&#8230;<br>　　第三个的题目：<br>　　在一个无向图中，寻找是否有一条距离为K的路径，描述算法即可，不用实现，分析算法的时间和空间复杂度，尽量优化算法。<br>　　OK，这个就是传说中的软肋了&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;我也就不把自己的答案写出来了（丢人啊），虽然后来仔细想想，我那个挫挫的方法也能够用&#8230;&#8230;只是效率&#8230;&#8230;<br>　　That's all. <br>转载请注明出自应届生求职招聘论坛 <a href="http://bbs.yingjiesheng.com/">http://bbs.yingjiesheng.com/</a>,本贴地址:http://bbs.yingjiesheng.com/thread-21638-1-1.html</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<img src ="http://www.cppblog.com/Walker/aggbug/136335.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Walker/" target="_blank">漫步者×&……%￥</a> 2010-12-13 22:01 <a href="http://www.cppblog.com/Walker/articles/136335.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>