techinterview.org
域名年龄: 23年1个月19天HTTP/1.1 301 永久重定向 服务器:nginx/1.0.15 访问时间:2015年05月21日 06:38:05 类型:text/html; charset=UTF-8 Transfer-Encoding: chunked 连接:keep-alive 语言环境:PHP/5.5.16 X-Pingback: http://www.techinterview.org/xmlrpc.php 目标网址:http://www.techinterview.org/ HTTP/1.1 200 OK 服务器:nginx/1.0.15 访问时间:2015年05月21日 06:38:05 类型:text/html; charset=UTF-8 Transfer-Encoding: chunked 连接:keep-alive 语言环境:PHP/5.5.16 X-Pingback: http://www.techinterview.org/xmlrpc.php 设置Cookie:PHPSESSID=eqvlsaj3fm50fahfc5fvtl6o44; path=/ 过期时间:1981年11月19日 16:52:00 缓存控制:no-store, 不缓存,必须更新, post-check=0, pre-check=0 其他指令:不缓存 Content-Encoding: gzip 网站编码:UTF-8
Tech Interview Search for: MenuGames Bookstore Building a Stack with a getMax() functionGetting a fair result with an unfair coinStoring 1 million phone numbersReverse a String100 Doors in a RowRed Marbles, Blue MarblesBumblebeeint atoi( char* pStr )Daughters’ Ages Building a Stack with a getMax() function Suppose you had a Stack class. Write a new class MaxStack which, in addition to push() and pop(), has a method getMax() which returns the largest item in the stack. Use your existing Stack class to store the stack’s contents. Don’t just use pop() to “dig” through your stack to find the max—do something that lets you return the max in constant time. Solution We could have an instance variable where we hold the max, but there’s a problem—when we pop that item from our stack it’s no longer the max. Now we have to “dig” through our stack to find the new max. Ideally we’d keep track of the current max as well as what the new max will be when that max is popped. The trick is to have two instances of Stack inside our MaxStack. One holds the actual stack contents, while the other (call it maxesStack) holds the maxes. Whenever we push() an item, if it’s larger than the top item in maxesStack, we also push it to maxesStack. Whenever we pop() an item, if it’s the same as the top item in maxesStack(), we also pop() it from maxesStack. So at any given point we can get the overall max in constant time be peeking at the top item in maxesStack. Getting a fair result with an unfair coin How can you get a fair coin toss if someone hands you a coin that is weighted to come up heads more often than tails? We are NY Tech asks: “How many unique areas of human knowledge have the right size of passionate users to make it as a Stack Exchange site?” Answer: 30,000. Storing 1 million phone numbers What is the most efficient way, memory-wise, to store 1 million phone numbers? Apparently this is an interview question at Google, although this seems like its a bit too easy. Reverse a String A typical programming interview question is “reverse a string, in place”. if you understand pointers, the solution is simple. even if you don’t, it can be accomplished using array indices. i usually ask candidates this question first, so they get the algorithm in their head. then i play dirty by asking them to reverse the … Read More 100 Doors in a Row Problem: you have 100 doors in a row that are all initially closed. you make 100 passes by the doors starting with the first door every time. the first time through you visit every door and toggle the door (if the door is closed, you open it, if its open, you close it). the second … Read More Red Marbles, Blue Marbles Problem: you have two jars, 50 red marbles, 50 blue marbles. you need to place all the marbles into the jars such that when you blindly pick one marble out of one jar, you maximize the chances that it will be red. (when picking, you’ll first randomly pick a jar, and then
© 2010 - 2020 网站综合信息查询 同IP网站查询 相关类似网站查询 网站备案查询网站地图 最新查询 最近更新 优秀网站 热门网站 全部网站 同IP查询 备案查询
2024-07-13 18:01, Process in 0.0067 second.