Pages

Wednesday, September 28, 2011

贡献一些面试题(GS,BarCap,Credit Suisse,etc.)

拿到offer,把面试过程中遇到的一些题贡献出来。我申请的主要是risk,偶尔有quant
strats。

C++及编程:
1)what is an object? difference between object and class;
2) difference between pointer and reference;
3) what is static variable? static function?
4) 一些片断挑错题;
5) 计算factorial;
6) 识别prime number;
7) 写一个程序从一本书里挑出有特定字母的词语。

数学、统计、brainteaser:
1) 有一个直径已知的圆,从圆周上随机挑两个点,问平均距离多少;
2) 什么是central limit theorem,假设是什么?
3) 讲出一个var=无穷的distribution,写出一个var=无穷的distribution的density 
function;
4) 假设有一张圆桌子,你和面试官轮流放硬币上去。硬币不能重叠放,也不能有一部
分悬空。放下最后一个硬币的人就赢了。问怎样放才能稳赢;
5) 100!有多少位数?

金融、金融数学:
1) 什么是VaR?如何计算?
2) OU process的各种性质;
3) 如何导出BS PDE?
4) 证明各种process是否martingale;martingale hits boundary的问题;
5) Local volatility model,stochastic volatility model及smile;
6) 近期时事。

Sunday, June 12, 2011

CS学生在北美求职升级经验心得

本人CS硕士名校非牛人,一年前去了一家中型软件公司做SD,不喜欢,刚刚跳去一家小HF.面试
的过程好像西游记一样,路途遥遥,艰险不断,怪物层出不穷,自己的本领也日渐增长,2年来承蒙
版上各路豪杰照顾分享,今日也算有个结果;特此拿出小弟所见所闻共勉,纪念找工作的艰辛,愿
大家早日心想试成,取到真经!

/***********************
        小测验
***********************/

首先来个小测验,看你能看懂多少
1.array,list,BST,Hashtable,queue,stack,suffix tree,collection...
2.BFS,DFS,DP,D&C,Greedy,Dijkstra,tree traversal,recursion,quick
sort...
3.A,F,G,L,M,O,T,Y...
4.OOP,GC,Polymorphism,interface,abstract class,singleton...
5.bar raiser,white board programming,lunch interview...

如果以上任何概念不能熟练给出详细解答,请在往下面看之后抓紧复习1.数据结构(这个如果一
个没看懂可以按后退关窗口了)2.算法3.公司背景4.面向对象编程5.onsite流程.全看懂了也别
骄傲,这其实只是很简单的小测验,拿笔每行接着写10项.

/***********************
      公司面试心得
***********************/

下面按照公司我大概讲讲面试题的注意事项,由于有不少是1年前的题目,记得不太清楚,我以框
架为主,后面主要讨论复习要点和经验教训:

A:phone interview会问到关于OOD的概念和设计,onsite有问过题:数组找定和,Hash
table溢出, isBST,Rome letter,GC设计,byte[] getIP(int),deadlock,优化搜索速
度.数组求定和是最最常见的问题,基本每两个interview就有一个问这个,后面还会说到,一定不
要陷入固定思维,自己多想想不同的condition下的解答.听说最近在狂面人,可以在linkedin上
面直接找到HR要面试.

F:现在已经很难进了,主页能找到一些puzzle,很多很tricky,不过也还算不难,觉得普通面
试题缺乏挑战的童鞋可以拿做当onsite前热手,phone里面主要是基础题目,只记得链表反转,以
OOP为主,没有onsite过. http://www.facebook.com/careers/puzzles.php

G:被问到都是非主流问题和设计,什么"估算躺在地上硬币总价值",无语.设计也都是开放性
的,没啥参考价值,可能天生相克吧.

L:很注重java的概念,例如hash原理,多态,继承,gc等的深层概念和implementation,对于
概念有点要求的过严了,但是还算是让人向往的公司吧

M:注重flawless的编程,pointer的操作(能用array/bitwise不要用hashtable),DP,
dictionary/index,recursion.最近狠狠的涨了一下工资,让人很眼红的说

O:基本只看GPA3.8以上或者内荐,面试主要是algorithm,SQL

其实我大公司的面试经历不算多,也只能这样点到为止,但是还有一些公司,招人规模不及以上,
但是我也稍微点评一下.

Bloomberg:变态的测试,据说除了c的测试外其他没有过的记录.面试也是集中与算法和数据
结构,以c/c++为主要背景,压力大工作辛苦薪水高,一但进黑名单貌似是永远不会考虑了

ebay:招人不是很给力,最好内荐,OOP为主,一流的流量一流的薪水二流的软件,我的意思不是
说ebay不好,而是说其实他家软件,尤其比起A来,还有很大上升空间,其实趁着软件还不够好参
与开发是种机会,你懂的

rapleaf:漫天广告,实际上没啥诚意,现在市场转好,建议不要考虑

D.E.shawn/two sigma/citadel:面试门槛很高,但是效率也很高,舍得花钱,就是录取
率不高,建议阅读相应金融知识,并且有相关实习经验或者大公司背景,new grad很有难度

laserfiche:坑爹专业户,如果你从没onsite经历可以去一下,否则就是浪费时间,薪水超
低(尤其以LA为背景)

ning:新兴social network,100人不大但也还算不错的startup,不过他们manager很对
不起我,估计我这辈子是不考虑了,推荐想做social network但是去不了F,L,T的

quantcast:强烈推荐,感觉非常棒,但是codetest也很难,时间很紧张,2个小时测试,到点
的时候只写出2/7个答案,4小时写出完美程序,大概200行的样子,加上10个testcase,然后
就悲剧了,估计就是嫌我慢

addepar:很个性的公司,先一轮phone,然后做蚂蚁大战,时间不限,
http://addepar.com/challenge.php,要是我在学校可能还有心情测一测
根本不太可能静心给他做这个,若是能达到400-600turn过关,那么可以拿到下轮面试,你要
是觉得自己很牛没有题做,试试这个

epic:狂招人,面试比较简单,需要准备presentation,有性格测试

cisco/emc/ibm/adobe:感觉对local看的很重,不太招外州的人

yahoo/SAP:没落中,需求量越来越小

apple:对SDE需求不大,有些ee的职位,手机卖这么好,没听有招人(店面不算)

GS/UBS/Citi/boa:看重GPA,如果你喜欢做纯技术,去了会后悔的;如果想做金融软件,但是
达不到bloomberg和hf标准,是个不错的跳板

fiverings:很小的HF,10几个人吧,问一下brain teaser和古怪的程序,有兴趣可以试一下,
老板是从jane street出来自己做的

其实还有数不完的公司,不过本人主要经历也就这些.

/***********************
        复习清单
***********************/

我只列出关键字和一些特别注意的要点,其实一个词可能包含无数知识点:
Array(pointer)
list(reverse,loop,ring)
tree(traversal,search)
sort
queue/stack(BFS,DFS)
hash table
string(suffix tree)
recursion
graph/greedy
divide and conquer
dynamic programming
bitwise
OOD(GC,serialization,exception,UML,singleton)
regular expression
deadlock/multi-thread
I/O,memory,buffer
testing(unit test,white box,black box,development cycle)
Network(TCP/IP,socket)
SQL(index,bcnf,3nf,optimization)
Scale(distributed system)
Security(buffer overflow,protocol)
Machine learning/AI
probability(bayes)
Web programming
最后是behavior(strength,weakness,goals)

参考书和网站:
crack the technical interview(强烈推荐)
programming interviews exposed(强烈推荐)
编程之美
data structures with java
algorithm design
database management system
computer networking
thinking in java
thinking in c++
software testing
java how to program
http://www.mitbbs.com/bbsdoc/JobHunting.html (还用多说么)
http://www.careercup.com (会上面的题不代表就能过面试!)
http://www.glassdoor.com
http://www.dice.com
http://www.javacertificate.net/core_java_iqns.htm
http://www.techinterviews.com/core-java-interview-questions
http://javaquestion.tripod.com/InterviewWithAnswer.html
http://www.freejavaguide.com/java-interview-questions.html
http://www.roseindia.net/interviewquestions/
http://www.geekinterview.com/Interview-Questions/J2EE/Core-Java
http://javaquestion.tripod.com/InterviewWithAnswer.html
http://www.indiabix.com/technical/core-java/

这里小小感慨一下阿三的团结,咱们怎么没有更多像印度玫瑰这样的网站呢...

/***********************
       经验教训
***********************/

最后一部分,琐碎的经验教训

1.对方电话里问你下周能不能来,一定要问清楚他们急不急用人,急得话要当机立断,我因此疏
忽本想拖延一下面试避免时间紧张,结果一周后被告知不用去了,四大皆空,干脆悲剧

2.地区是一个很重要的因素,如果你还没开始h1b或者绿卡,在找工作受阻的情况下可以考虑申
请opt然后搬去加州或者纽约,在local找,很多公司为了省phone的多回合和onsite的开销,
只找local或者优先在local找.至于有些在职的人想辞职裸奔挂语言学校,也是个办法.

3.不要背题.迄今为止我还没见到过一模一样的面试题,优秀的面试官一定不会只准备所谓经典
的面试题,一定有改动和引伸.举个例子,数组找定和很简单吧,怎么不用hash table照样
O(n),找3数定和?4数(有O(n^2)解)?负数?已排序数列?写白板!再举个例子hash table大
家都知道,让你用数组实现?hash function?碰撞处理?碰撞处理方法的利弊比较?equal和
hashcode的关系?写白板!希望大家准备的时候能够多问自己问题,写程序也不要只完成题目,多
想想如果哪个要求换了应该怎么改.

4.练习口语.比起阿三,老美不见得喜欢中国的口音,很多人的发音和语法不正确,自己从来没用
心改正过.这里推荐一款iphone的免费app-dragon,
http://itunes.apple.com/us/app/dragon-dictation/id341446764?mt=
是一语音识别软件,你找一篇新闻,认真读看看老美的软件能听懂你多少,反复训练,更上一层楼.
说话的时候尽量嘴巴变化明显一点,试着拉长放慢大声和夸张的读每个单词,尤其是字母lnr的
卷舌鼻音

5.实习经历还是很重要的,重要程度多过绝大部分in class project,争取毕业前能在美国
公司里面有过实习经历.

6.linkedin其实是一个很好的平台,很多recruiter在上面搜罗人才,你要表现的活跃一些,
完善自己的资料.另外如果通过朋友等渠道,你可以找到recruiter的邮箱,一定要主动自报家
门,我干过无数回了,直接email给recruiter,附上简历,说明背景,百试不爽,基本每次都有
面试

7.搞好和同学前辈的关系,最大化争取referral(朋友的朋友也行),有面试什么都能靠你自
己,没面试你自己再牛也不行

8.白板练习很必要.为了面试我用eclipse至少写了60个函数的题目,但是换成白板/白纸,还
是无法每次写出flawless的程序,这个必须多加练习,而且尽量找一些自己没听过的题目或者
变形的题目

9.准备好所有工作经历包括实习的描述,控制好时间,另外着重准备1-2个对你来说重要的
project/design,一定要做到拿起来就能说,而且说的简洁明了重点突出,让不很懂的人也能
听明白

10.behavior question要花时间准备,准备过的话一问就能问出来,说话要简洁,用多个简
短的句子回答,不要用冗长的从句.给面试官一个好的印象.

11.屡试不行的童鞋请考虑 i.改简历 ii.monk interview iii不同type的职位.原则上
找能给你反馈的人的意见,反馈可以说是非常难得到的,是指引你进步的关键.monk
interview要涉及技术和behavior,而且面试人要认真准备,问题要有深度,当场要卡时间写
白板,不要觉得认识面试人就跳过诸如自我介绍,project描述等环节.

12.木桶原理,找到自己的不足,尽量提高综合能力,不要让任何不足拖你后腿.举个不一定合适
的例子,如果你是路痴,面试前多查查map要不就打出来,留一个紧急求助电话像是tax或者HR
的电话,一定要保证按时到达.路痴不能怪你,不守时那就是你的责任.现在公司招人,基本上都
是找综合能力强并且有亮点的人,弥补你的短板往往能更加有效的留下好印象.

13.列个表或者找个日历,合理安排面试顺序和集中程度,确保面试前对公司有所了解,尤其是要
看至少一遍job description,知道他们的需求是什么.这里废话一句,对于dream
company,最好不要放在面试经历少或者时间仓促的时候,如果你从来没去过onsite或者很久
没去过onsite,用其他公司热身是有必要的.一般一年左右的黑名单还是很难熬的,况且有些像
F这样的公司,2年前和现在的口气明显就不一样,现在连要个面试都很难.

14.学会换位思考,从面试官公司角度考虑他究竟在考察你什么.如果可以,你甚至也可以给别
人做interview,你会体会良多.crack technical interview里面说的比较夸张,面试官其
实在找"Would I have a beer with this guy?"的答案,但是你不可否认的是,他们如果觉
得和你在一起不舒服,随便找个借口就可以把你打发了.

15.面试过程中很多东西是无形的,面试前题目,公司招人的主要原因,老板性格态度,职位竞争
的激烈程度,面试评价标准等等,所以要尽可能的把握自己看的见的,技术要点,措辞态度,白板
编程等等.未知因素不由得你,不要老想着哪里有窍门哪里有小道消息来投机取巧;超越自己,把
握自己才是真正的提高.

16.这里再废话一段,面过这么多公司,感觉中国人还是比较受压迫,比起阿三,中国人在软件
公司中层的人数明显少,很少人接触到核心技术和做决策.准备面试的时候,要多与朋友交流
互相帮助,阿三老美的优点要尽量学来,以后职场做的久了,也要多帮助后生.我们的爷爷辈受
尽别人压迫欺负,父辈受自己人欺负,能提供机会我们出来,很不容易.我们这一代其实是肩负
着历史使命的,而在美国的各路精英应该是民族复兴的领军人,希望有朝一日中国能有更多的
AFGM为世界贡献优秀的软件.

话说到这里也差不多了,以上的话也都是小弟自己的体会,有不到位的地方也希望和大家讨论
切磋.关于详细的每家的面试题,还有比本版(尤其是精华贴)更好的地方么.最后用一句话与
大家共勉,机会青睐有准备的头脑,还等什么,继续打怪升级吧!

PS给小编:咱们文章格式小悲剧啊,换行换的叫一个蛋疼

Wednesday, April 6, 2011

C++ Programmer Example Cover letters:

Dear Cathy Jones,
My name is Jimmy Cregline and I am writing to you to apply for the Software Engineering job advertised on seek.com.au
I am currently employed as a Software Engineer and Project Manager at an online marketing company. The main technologies I use daily are OO PHP, MySQL and Perl.
I also have experience in programming with object oriented C++. My former employer was NetFlix. I was part of a development team that designed and implemented a DVD dispatching system using Microsoft Visual C++. This software has since been licensed and is currently used all around the world. Telstra Bigpond is one of the more well known licensees.
I'm looking to advance my Software Engineering career by learning new technologies and extending my C++ experience. I have not had any experience with true real time systems but I have recently been involved in time sensitive projects in telecommunications. I was heavily involved in a team that developed an advertiser sponsored telephone system called sponsortel.com which involved processing and routing live telephone calls around the world in real time. This kind of technology excited me as it was new and challenging.
I'm a hard working and reliable person always looking to better myself and learn new technologies and skills. I think I have a lot to offer BGE Systems and a career at BGE Systems would be very rewarding. I'm sure if I am given the opportunity to meet with you I will be able to tell you more about my achievements and aspirations.
I look forward to meeting with you.
Kind Regards.
Jimmy Cregline

Web Developer Example Cover letters:

Dear Wayne,
My name is Jimmy Cregline and I am writing to you to apply for the Senior Web Developer job advertised on seek.com.au
I have been programming with OO PHP for 5 years and have completed many large projects.
I am currently employed as a Software Engineer and Project Manager at an online marketing company. The main technologies I use daily are OO PHP, MySQL and Perl.
My former employer was NetFlix. I was part of a development team that designed and implemented an online DVD rental system. This software has since been licensed and is currently used all around the world. Telstra Bigpond is one of the more well known licensees.
I'm looking to advance my Software Engineering career by learning new technologies and completing new and exciting projects.
I'm a hard working and reliable person always looking to grow my knowledge and learn new technologies and skills. I'm sure if I am given the opportunity to meet with you I will be able to tell you more about my achievements and aspirations.
I look forward to meeting with you.
Kind Regards,
Jimmy Cregline

Sample Computer Software Engineer Cover Letter

••••••••••••••••••••••••••••••

Curtis Girard
678 Wallaby Lane 
Any City, USA 23232

June 10, 2006


Mr. Thomas Manion
Hiring Manager
Dyna-Mint Software Designs
22 Dogwood Road
Any Town, USA 78956

Dear Mr. Manion:

I understand from your listing on JobBankUSA.com you are in the market for a trained computer software engineer with a minimum of six years of experience. I am one who qualifies. I earned by B.A. from Balsam University and I have designed and tested software for ILB Computer Systems in Chicago, Illinois. I served as department head the last year I was there.

My specialty is software for small businesses. I am a committed employee with the ability to work as a team member, to lead and to follow, depending on the situation and responsibilities assigned to me.

Would you like to meet to talk over this job? I'd enjoy speaking with you in person. Please call me on my cell phone: 785-897-3434 to set up an interview at your convenience. Thank you for considering me for this opening and for reading my cover letter and resume.

Sincerely,


Curtis Girard

Enc: resume and cover letter

Legal Cover Letter For Salary Negotiation Before Joining

Sample / Example Legal cover letter for salary negotiation

XYZ
(Sender's Address)
6 April 2009
HR Manager
ABC Ltd
(Company's Address)
Dear Sir/Madam
I am pleased to have been selected for the position of a barrister in ABC ltd. I have identified your organisation as having strong growth opportunities through my job search. I want to say again how extremely pleased i am to have to work with this organisation.
However i would want to discuss the compensation as it is less than i expected. My work experience in the industry and research projects warrants a higher compensation than what is being offered. I have worked with thebest attorneys in supreme court and have a fair knowledge of both criminal and civil trials. I have handled all my cases with utmost care and you can definitely expect confidentiality with my work. Also i have a knack for immediately building a good rapport with my clients.
I have sufficient certificates to support my credentials that will reaffirm your faith in my work. I understand that the organisation has its own limitations but i'll be obliged if you could look into the matter. My work exposure is extensive.
I hope that we can come to terms on this matter and begin our happy association as soon as possible.
Awaiting your response.
Yours sincerely
XYZ

Thank you cover letter to referrer

Legal Cover Letter Example / Sample

Thank You Letter to Referrer

XYZ
(Sender's Address)
5 April 2009
Mr A.K Das
Senior Law Consultant
(Company's Address)
Dear Sir/Madam
I take this opportunity to thank you for putting aside your valuable time and providing me with an insight on my future career options. The discussion taken with you has made me more clear about my job search. I express my gratitude for your critical and constructive feed back.
I have updated my resume taking up your suggestions highlighting my strengths and skill set. I will send you a copy of the same. Also on your suggestion, i have started reading upon few civil cases and prepared their analysis. I will definitely discuss them with you. Also i have started taking training on practical issues under Mr. PQR whose a well known Attorney. It has been of great help to get the grip of the work.
Thank you, once again, for taking time from your busy schedule to see me. Your support and guidance has put in me a new energy to fight for the best. I am grateful for your support. Looking forward to meet you.
Yours Sincerely
XYZ

Oracle Programmer Cover Letter

Sample IT Cover Letter Examples / Templates - Oracle Programmer

XYZ
(Sender's Address)
18 April 2009
HR Manager
ABC Ltd
(Company's Address)
Dear Sir/ Madam
This is in regard to the job advertisement for the position of the Oracle Programmer in ABC Ltd listed in the National newspaper on 15 April 2009. I want to apply for the same. I aspire to be associated with your company. ABC Ltd has a strong market position in the field of Electronics. And i will be more than glad to contribute to its success. 
I am an experienced oracle programmer analyst for past 3 years in the information technology development department of PQR Ltd. Hereby i provide you with a brief overview of my skill set:
  • I am comfortable with coding, testing, and documenting of programmes along with analysing them.
  • I have assisted my seniors in the design phases of system development.
  • Also i carry an extensive experience in XML, Javascript, and CSS.
  • I understand the importance of working in teams and have a considerable ability to communicate internally and externally. I am a fast learner and enjoy the experience of working in a fast paced enviornment.
Hope to hear from you soon. i have enclosed my detailed resume for your further reference.
Thanking You
XYZ
(Enclosed Resume)

Web Developer Cover Letter

XYZ
(Sender's Address)
20th April 2009
HR Manager
ABC Ltd
(Company's Address)
Dear Sir/ Madam
This is regarding the job vacancy of a web developer in your company «ABC Ltd».  I am interested to apply for the same. Here i provide you with brief details of my educational background, work experience and skills.
I hold a bachelor's degree in Computer Science. My proficiency accounts in web services, WSDL, SOAP, Java/J2EE, JMS. My web developing experience includes a project in which I created an e- commerce site for a business house using Java Script.  Apart from this i carried out the responsibilities like Database Design, Updating System and the Web Server, Web Applications Development.
My supervisory skills were demonstrated in my last job by training, mentoring, and evaluating 3 administrative support employees, which resulted in a decrease in staff turnover. My experience with command and control (C2) communications systems is considerable and also i am familiar with enterprise integration patterns apart from the basic requirements.
I have working knowledge of XML, XSLT, DTDs, XML schemas, etc. and  of web graphics. My communication skills have evolved over the time and i am comfortable with english and spanish.
Hope to hear from you soon.
Thanking you
XYZ

Project Manager (PM) Cover Letter

Sample IT Cover Letter Examples / Templates - Project Management / PM

XYZ
(Sender's Address)
13 April 2009
HR Manager
ABC Ltd
(Company's Address)
Dear Sir/Madam
I am writing this to express my interest in the job vacancy at the position of a Software Project Manager listed with ABC Ltd.
From our discussion we had over the phone, i was immensely impressed by the company's background and work profile.  Here by i provide you with an overview of my capabilities and experience. I assure you that they will match to your expectations for this profile. I hold professional qualification in project management from the renowned «PMI».
My experience with PQR software Ltd. included:
  • Software crisis and software development methodologies
  • Approaching problems through artificial intelligence methods
  • Case approach, meetings and workshops, contract negotiation
  • Estimation techniques, project planning and scheduling, formal reviews
  • Working with management teams and shaping project strategy in handling high risk projects
Also i have a comfortable hand at PRINCE2. Training and coordinating between various project  teams has made my interpersonal skills even better which were useful in maintaining  client relationships. I have enclosed my detailed resume along with for your reference. Hoping to be in association with ABC Ltd. soon .
Yours Sincerely
XYZ

How to Write a Cover Letter for a Project Management Job

Project management is a skill set that is in demand. Use a cover letter to introduce yourself and your resume to an employer needing your project management expertise. For maximum impact, draw the employer's attention in your cover letter to what qualifies you to be the best project manager for that company.

Difficulty:
 
Moderately Easy

Instructions

things you'll need:

  • Good quality resume paper (but nothing too fancy)
  • Envelope and postage stamp
    • 1
      Conduct research on several job boards to compare job advertisements for project management jobs. Look at advertisements for jobs such as project manager, project executive and project coordinator. Write down the common requirements necessary to fill the jobs such as attention to detail and planning skills, experience with budget management, ability to lead a team through all phases of a project and PMP (Project Management Professional) certification.
    • 2
      Consult eHow's "How to Write a Formal Business Letter" for information on formatting your cover letter.
    • 3
      Obtain the person's name who is responsible for hiring for the project management position you are seeking. Call the company and ask the receptionist for the name. Use this person's formal name in the greeting of your cover letter.
    • 4
      Write in the first paragraph the name of the project management position you are seeking, the name of the company and where you heard about the job opening. State that you believe your background in project management makes you a great candidate for the position.
    • 5
      Convince the reader in the second paragraph that you can meet the project management needs of the employer because you have the right skills, experience and education. Use key words like budget, risk, quality, planning and team leadership. Include accomplishments that explain how you solved a problem such as "Successfully turned around a failing project, staying within a defined budget and time frame, that resulted in a project of the year award."
    • 6
      Thank the reader for his time and consideration in the final paragraph of your cover letter. Request an interview. Include your phone number and email address.
    • 7
      Proofread your letter to ensure that all punctuation, grammer and spelling is correct.


Read more: How to Write a Cover Letter for a Project Management Job | eHow.com http://www.ehow.com/how_2049345_write-cover-letter-project-management.html#ixzz1Ikkj8DBa

Thursday, March 24, 2011

顶风狂发G面经,顺求bless

FYI. Wed Mar 23 20:56:21 2011, 美东 
1.给字符串求频率最高字符。字符串大咋办,多核咋办。

2.俩数组交集。有序或无序。

3.实现cache.

Thursday, March 17, 2011

some hints about hg(mercurial)

we are switching from subversion to mercurial now.  something is different to them. so I record some hints here how we change our daily software development work.

* in subverion, we usually to merge one changeset. but in mercurial, it is not the same thing.
  * if the changeset is on different branch, we can merge the two branch. that means merge thsi changeset. :) totally different to subversion, ha. we can't only merge this changeset, we have to merge the two branch. but don't worry about the old changesets on the branch, mercurial is very smart to recognize the old same changesets , so it won't make conflicts. the command like this: hg merge xxx(the branch name of the changeset which you want to merge), of course the current branch should be the branch you are working on.
  * if the changeset is on one of ancient branch, you can only use the rebase to do this merge. that means rebase one parent from the new changeset. something like this:  hg rebase -s (the revision number which you want to merge) -d (the target branch you want to merge, or let's say the branch you are working on)

* if we have some uncommitted changes on the working directly, we can't do merge stuff, because mercurial forbidden to do this, that means he need a clean working directory. then how we can clean those uncommitted changes?
   * if they are really some uncommitted changes you do, then just do this command: hg revert --all.
  * if they are some uncommitted merge, then you can do hg revert to clean them, seems it is boring how to abort the uncommitted merge. I have a trick to do this: hg update -C.  the -C option will clean the working directory.

* if you have some local commits which you don't want to push, you can use hg strip to delete them from you local working directory.

so that's it, have fun and enjoy the mercurial.




Tuesday, March 8, 2011

Easily Installing Vim 7.2 From Source

in debian lenny, the vim is 7.1, if you want to use some new feature plugin, you have to update your vim from 7.1 to 7.2. but no vim7.2 debian package for lenny, so we have to install vim 7.2 from source.


Monday, March 7, 2011

what's the meaning of SDE and SDET from Microsoft?

* SDE may be:
  * Software Development Engineer
  * Software Design Engineer
 
* SDET 
* Software Development Engineer in Test
* Software Design Engineer in Test

Saturday, March 5, 2011

some iterview questions from Amazon

附电话面试题:

一面:

1. write a function to count zero bits in an integer, read code on the phone

2. use OOD to design an HTML parser, list all the classes and methods
其实就是DOM的简化,当时没反应上来,答得不好

3. what’s the difference between old style Python classes and the new style

4. Unix, how to find the file with the longest path name?

5. Unix, a million webpages, each page may have some phone numbers with two
formats (XXX)XXX-XXXX, XXX-XXX-XXXX, how to find them out and update them

6. A million of ids and more coming, how to tell if an id is duplicated.
what data structure, what’s the complexity

7. what if amazon website is slow?
(follow up). what if app server is idling but database server has high load?
(follow up). how to design cache on the app server?

二面:

1. (老题) find out pairs in an array that sum to a given sum.
write code on paper and read to the interviewer (character by character).

2. (OOD) Design classes for actors and movies, implement at least these two
methods:
actors->getMovies()
movies->getActors()
what to do if initializing actors needs the movies objects while
initializing movies needs the actor objects.
how to search for actors that starred in movies that were on show at a given
time.
discuss different approaches.

3. How to improve the current IMDb website, how to design the mobile version
(iphone/Android)

Thursday, March 3, 2011

Ed2k links handling in Linux

The way to make aMule handle your ed2k links on your favorite web browser will depend on which web browser you use and which operating system you have installed. So, here's a list of mini-HowTos for each of the most popular web browsers and operating systems.

Tuesday, March 1, 2011

讨论:merge两个有序数组

一个简单的情况:
假设a中元素都比b中的大
b会越界

标准的应该是3个循环
: 有更优的方法么? thx!
: k=i+j
: a[i],b[j],c[k]
: int ii=jj=kk=0;
: while(kk<k){
:         if(a[ii]>b[jj]){
:                 c[kk]=b[jj];
:                 jj++;
:         } else {
:                 c[kk]=a[ii];


so:
k=i+j
a[i],b[j],c[k]

int ii=jj=kk=0;
while(kk<k){
  if( ii==i || (jj<j && a[ii]>b[jj]) ){
    c[kk]=b[jj];
    jj++;
  } else {
    c[kk]=a[ii];
    ii++;
  }
  kk++;
}


so:

void merge(int *a, int sza, int *b, int szb, int *c) {
    //User is responsible for allocating array c
    int i = 0;
    int j = 0;
    while( i < sza && j < szb ) {
        if( a[i] <= b[j] ) {
            c[i+j] = a[i];
            ++i;
        } else {
            c[i+j] = b[j];
            ++j;
        }
    }
    while( i < sza ) {
        c[i+j] = a[i];
        ++i;
    }
    while( j < szb ) {
        c[i+j] = b[j];
        ++j;
    }
}

实现一个整数除法的函数,不使用除号,可以使用加号、减号和乘号,函数只返回 : 商.

you can only get 60pts with this algorithm

【 在 yesim (yesim) 的大作中提到: 】
: 五、实现一个整数除法的函数,不使用除号,可以使用加号、减号和乘号,函数只返回
: 商.
: function(int x,y){
:   n=x;k=0;
:   while(n>y){
:     n=n-y;
:     k++;
:   }
:   return k;
: }
: ...................

汽车出租(Car Rental Agency)的系统的oo设计

设计一个汽车出租(Car Rental Agency)的系统。他先问我如果要实现
vehicle search,需要哪些类;然后又问要实现rent a car,又需要哪些类;最后问如
果快到了交车截至时间,需要向用户发送提醒的邮件,应该怎么做。

abstract calss car
calss BMW extends car
calss Honda extends car
....

interface CarManager
class <T extends Car> CarManagerImpl {
  List T search(Class<T> clazz){
   
  }

  T search(Class<T> clazz){
   
  }
 
}

class User {
  List<UserCar> usercarList;

  User();
 
  boolean Rent(T entry){
    usercarList.add
  }

}

class <T extends Car> UserCar {
  List<UserCar> usercarList;
  ......
 
}


class Monitor implement Runnable {
  public boolean doMonitor{
    List<UserCar> usercarList = UserCar.getUsercarList(String condition)
    for(User user : usercarList){
      sendEmail(getUser().getEmail());
  }
}

讨论:反转一个整数,如12345->54321

反转一个整数,如12345->54321
当时写了个这么个东西(面试官假设输入是正整数):
int reverse(int n) {
   res = 0;
   while(n != 0) {
      res *= 10;
      res += n % 10;
      n = n / 10;
   }
   return res;
}

然后面试官问,如果n<0怎么办;我说判断一下,然后把n = -n,然后重复;
问题就在这里,他说不行,正确的做法是n = -1 * n;我不明白为什么是这样?


n为负数,你想把它整成整数
不用 n = -1 * n;  用啥?
或者你用  n = 0 - n; 也行

-n 编译都不通过

居然都不做防止溢出的?
正负数的溢出不等

The syntax
n = -n;
is valid in C and C++.
 

Monday, February 28, 2011

find the shortest substring covering all given characters.

A long string text, given some characters, find the shortest
substring covering all given characters.
请问大家有没有想法,谢谢

quick thoughts:

两个指针p,q,先前进q直到cover了所有characters,记录当前长度
然后单步前进q,每次都尽量前进p使得pq间仍旧cover了所有characters,
maintain最短长度

需要用一个map维护出现的字符

复杂度O(n)因为相当于scan了2次

假设str[0..n-1]表示整个字符串。基本思路是从str[0]开始,以每个位置作为substring的起点,从该位置往后直到substring能cover所有字符。那么最多就有n个起点。问题是,如何每次只用O(1)来确定substring长度。

我想可以用一个辅助数组记录每种字符出现在字符串中的位置。例如字符a出现在str[0]和str[20]两个地方。假设当前已经确定以str[0]为起 点的substring长度。接下来应该确定以str[1]为起点的substring长度。该substring丢弃了str[0],所以必须要至少在 str[20]结束,否则字符a没被cover。这就是基本思路。

我用一个例子解释整个算法。假设字符串包括0到9的数字,整个串如下
0247324596818329654001378
第一步扫描字符串,记录下每种字符位置,如下
0:0,19,20
1:11,21
2:1,5,14
3:4,13,22
4:2,6,18
5:7,17
6:9,16
7:3,23
8:10,12,24
9:8,15

第二步,以str[0]为起点,substring的终点在str[11].
接下来,以str[1]为起点,因为丢弃了str[0],即字符0,那么从辅助数组可以找到下一个字符0出现在str[19],因此substring结束于str[19]。
这样每次substring起点往后一个字符,用O(1)时间可以确定结束位置。

随机数讨论

rand5()是没有能力只通过一次随机数的产生,和一些四则运算
,来获得更大范围的随机数的。
(前提是,这里说的都是整数哦。。。如果是实数范围的话另当别论啦。)
所以必须通过多次rand5()才行呢


Expand a random range from 1-5 to 1-7

int i;
do
{
  i = 5 * (rand5() - 1) + rand5();  // i is now uniformly random between 1
and 25
} while(i > 21);
// i is now uniformly random between 1 and 21
return i % 7 + 1;  // result is now uniformly random between 1 and 7



WHy can't I just put

i = 6*(rand5()-1);

* 1没有保证平均概率
* 2返回的数值的范围也不对呀


5*(rand5()-1):产生0,5,10,15或者20
5 * (rand5() - 1) + rand5()就是1-25之间的随机数
如果我没有记错的话,后面那个while应该是:
if(i<21) return i%7

while(i > 21);
// i is now uniformly random between 1 and 21
return i % 7 + 1;
产生的是2-5,就不对了

至于楼主的做法,
i = 6*(rand5()-1),产生的是0,6,12,18或者24

面经

Amazon 面试题
grep不愧为Amazon的最爱问题。
两次电面都问OOD...不容易。


在网上申请的SDE职位。一共两轮电话面试,一轮onsite。

第一轮电话面试:
1、解释Hash Table,包括“可以用什么数据结构实现hash table”,“what is a
good hash function”,“什么是load factor”。

2、算法:删除一个给定数列中重复的元素。

* 这道题看起来简单但是还是很多陷阱啊。。。
比如删除是什么意思?只是把array element mark为一个不可能的值(比如-1),还是
输出一个崭新的没有重复的数列。

3、merge两个有序数组。要求先给他解释算法,再写代码。他当时给了我十分钟的时间
,让我写好以后发到他邮箱里。

k=i+j
a[i],b[j],c[k]

int ii=jj=kk=0;
while(kk<k){
        if(a[ii]>b[jj]){
                c[kk]=b[jj];
                jj++;
        } else {
                c[kk]=a[ii];
                ii++;                  
        }
        kk++;
}


4、OOD:设计一个汽车出租(Car Rental Agency)的系统。他先问我如果要实现
vehicle search,需要哪些类;然后又问要实现rent a car,又需要哪些类;最后问如
果快到了交车截至时间,需要向用户发送提醒的邮件,应该怎么做。

第二轮电话面试:
1、Favorite project。

2、你最喜欢的排序算法,它是怎么工作的,有什么优点和缺点。我说的是选择排序,
他又问有什么排序算法比它的时间复杂度小,并且同样要描述一下它们是怎么工作的。

3、算法、写代码:
给了两个数组,要求找出他们之中相同的元素,并且将相同的元素存储在一个新的数组
里,再输出。如果数组里有重复的元素,比如array1中有四个5,array2中有两个5,那
么新数组里只存储两个5。要求我写代码,再念给他听。

4、OOD:设计restaurant reservation系统。

5、好像是一个开放性问题,我没有完全理解:log file中存储了很多order的信息,每
个order都有一个oid,字符串格式(xxx-xxxxxxx-xxxxxxx)。要求从log file中把所
有的oid都提取出来,问我怎么做。

on-site:
一、给定一篇文章,用户想要搜索一个单词,要求给出搜索单词的建议(就像一般的搜
索引擎的那种功能)。要求描述算法、复杂度并写代码。

二、先问了几个行为问题。然后问了两个简单的链表问题,单链表中查找倒数第n个数
和判断链表中是否有环。编程题问的是boggle游戏的问题:给定一个4*4的矩阵,每个
位置有一个字母,可以从一个位置跳转到周围八个相邻位置中的任何一个,但不能跳到
已经访问过的位置,要求找出所有的单词(假设给定了一个词典)。
http://en.wikipedia.org/wiki/Boggle

三、午餐,一个经理问了一些简历上的projects和实习的经历,然后又介绍了一下他们
组的工作。他说这次面试我的主要是Kindle组的。

四、不是Kindle组的,我估计是传说中的bar raiser。第一个问题是给了一个很大的文
件(不能完全放入内存),其中每一行存一个整数,要求判断这个文件中的数有没有重
复。然后是一个开放性问题:一台服务器每过三天就要挂一次,需要重启才能再次使用
,每次重启需要一分钟的时间;问有什么方法能解决这个问题。

* 服务器那个题我答的不好,因为老是不知道他在问什么,他想要的答案是什么。反正他
给了我很多提示,比如可以用交替使用两台机器,还需要一个load balancer,这样可
以在一台服务器挂的时候正好用上另一台正常工作的服务器,再重启挂的这个机器。


五、实现一个整数除法的函数,不使用除号,可以使用加号、减号和乘号,函数只返回
商。
--

文件找重复的那道题我觉得可以用hashtable,也可以external sorting。hashtable有
个问题是如果内存中放不下这个哈希表的话怎么办?我说可以使用多台机器,每台存放
一定范围内的数字(类似于MapReduce中map的过程),然后再分别对每个机器处理。


上来就一个问题,设计一个网上预定飞机票的系统

讨论了50分钟左右,弄的很细,每个class里有啥variable,啥method,都要说. 比如
Controller class谁去call, 怎么用Controller class. 还有内存怎么寸(不用数据库,
全存memory里),用什么数据结构,(他提出hashtable),什么作为key,什么作为value
一开始还好,后来纠结在一个如何给用户一个指定日期的航班信息,因为我没有存日期,
最后时间快到了,他让我把想好的设计发邮件给他...
 

贪心算法

贪心算法(又称贪婪算法)是指,在对问题求解时,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,他所做出的仅是在某种意义上的局部 最优解。贪心算法不是对所有问题都能得到整体最优解,但对范围相当广泛的许多问题他能产生整体最优解或者是整体最优解的近似解。

the workflow working on a team using mercurial

When you’re working on a team using mercurial, your workflow is going to look a lot like this:
  1. If you haven’t done so in a while, get the latest version that everyone else is working off of:
    • hg pull
    • hg up
  2. Make some changes
  3. Commit them (locally)
  4. Repeat steps 2-3 until you’ve got some nice code that you’re willing to inflict on everyone else
  5. When you’re ready to share:
    • hg pull to get everyone else’s changes (if there are any)
    • hg merge to merge them into yours
    • test! to make sure the merge didn’t screw anything up
    • hg commit (the merge)
    • hg push

Sunday, February 27, 2011

an idea about farm

buy or rent a woods, or a fruit tree farm, there should be a lot of glasses and bugs and insects, then we can raise a lot of chicken, those chicken will be very delicious because their are raised like wild chicken in the mountain, eating worms and insects and earthworm, not feed. so I believe the taste of their meet will be the same as the wild chicken. also we can provide a hotel and restaurant to cook those kind of wild meat. I think the business will be good.  so the good idea for a good farm.

Saturday, February 26, 2011

an idea about elearning

I have worked in e-learning industry for a long time. so I am thinking, why not develop a python e-learning system and run it on google platform, I can provide the chinese course, chinse history, chinese geography, chinese math to people, especially the chinese people who immigrate to foreign country, they hope their children can learn something about china. I think this is a excellent idea. I will plan to do it.

Tuesday, February 22, 2011

Using Threads in Twisted

* the benefits of twisted.thread.

* how to use the thread of twisted.

Hash - Eternally Confuzzled


A hash table, put simply, is an abstraction of an array that allows any value to be used as an index. While an array requires that indices be integers, a hash table can use a floating-point value, a string, another array, or even a structure as the index. This index is called the key, and the contents of the array element at that index is called the value. So a hash table is a data structure that stores key/value pairs and can be quickly searched by the key. Because insertion and removal are operations dependent on the speed of the search, they tend to be fast as well.
To achieve this magic, a hash table uses a helper function that converts any object into an integral index suitable for subscripting the array. 

FYI: I have 1337 coins

Here is an interview question you would expect from a typical Google interview, which is an interesting problem itself. Different solutions from multiple perspectives are provided in this post.
There are n coins in a line. (Assume n is even). Two players take turns to take a coin from one of the ends of the line until there are no more coins left. The player with the larger amount of money wins.
  1. Would you rather go first or second? Does it matter?
  2. Assume that you go first, describe an algorithm to compute the maximum amount of money you can win.
U.S. coins in various denominations in a line. Two players take turn to pick a coin from one of the ends until no more coins are left. Whoever with the larger amount of money wins.

use hash to improve the performance

two arrays, too loops, usually the complex will be O(n*n).
but if we use a hash dict to store one array, then we can go through every item in the array filter by the hash dict directly, that will be very fast, and the complex only be O(n+n).