08 2014 档案
摘要:n个数字(0,1,…,n-1)形成一个圆圈,从数字0开始,每次从这个圆圈中删除第m个数字(第一个为当前数字本身,第二个为当前数字的下一个数字)。当一个数字删除后,从被删除数字的下一个继续删除第m个数字。求出在这个圆圈中剩下的最后一个数字。这个问题在wiki上叫约瑟夫斯问题。一开始的序列是S(n): ...
阅读全文
摘要:根据上排给出十个数,在其下排填出对应的十个数 要求下排每个数都是先前上排那十个数在下排出现的次数。 上排的十个数如下: 【0,1,2,3,4,5,6,7,8,9】举一个例子, 数值: 0,1,2,3,4,5,6,7,8,9 分配: 6,2,1,0,0,0,1,0,0,0 0在下排...
阅读全文
摘要:题目:n个数中,求最小的前k个数。这道题在各个地方都看到过,在国内出现的频率也非常高。面完阿里回来听说这道题又被考了,所以还是决定回来写一写,对于这种高频题。。。顺便再吐槽一下阿里的面试,我竟然一道题都不用做,只是纯粹地过简历。。。导致我都不知道我究竟错在哪里。解法:1. brute force。 ...
阅读全文
摘要:dijkstra算法,最简单的实现需要$O(|V|^2)$。用binary heap实现,可以优化到O((|V|+|E|)lg|V|),如果用fibonacci heap的话,可以优化到O(|E|+|V|lg|V|)。如果图是密集图的话,那这个优化效果也不好,接近$O(|V|^2)$。fibonac...
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 5 template 6 class Heap { 7 public: 8 Heap():n(0), capacity(100) { 9 this->ar...
阅读全文
摘要:死锁的四个条件互斥占用等待非剥夺循环等待死锁的解决方案死锁预防间接预防:防止前三个条件中的任何一个的发生直接预防:防止循环等待的发生死锁避免进程启动拒绝:不启动任何一个可能发生死锁的进程资源请求拒绝:拒绝可能发生死锁的资源请求死锁检测死锁检测算法恢复策略:一旦检测到死锁,就要立即恢复。
阅读全文
摘要:RAID 0RAID 0亦称为带区集。它将两个以上的磁盘串联起来,成为一个大容量的磁盘。在存放数据时,分段后分散存储在这些磁盘中,因为读写时都可以并行处理,所以在所有的级别中,RAID 0的速度是最快的。但是RAID 0既没有冗余功能,也不具备容错能力,如果一个磁盘(物理)损坏,所有数据都会丢失,危...
阅读全文
摘要:At the scale that Facebook operates, a lot of traditional approaches to serving web content breaks down or simply aren’t practical. The challenge for ...
阅读全文
摘要:Facebook Chat, offered a nice set of software engineering challenges:Real-time presence notification:The most resource-intensive operation performed i...
阅读全文
摘要:Web front-end written in PHP. Facebook's HipHop Compiler then converts it to C++ and compiles it using g++, thus providing a high performance templati...
阅读全文
摘要:11年的blog.Facebook Messages seamlessly integrates many communication channels: email, SMS, Facebook Chat, and the existing Facebook Inbox. Combining al...
阅读全文
摘要:转自09年的blog,因为facebook在国内无法访问,故此摘录。The Photos application is one of Facebook’s most popular features. Up to date, users have uploaded over 15 billion p...
阅读全文
摘要:In the traditional model, the life cycle of a user request is the following:Browser sends an HTTP request to web server.Web server parses the request,...
阅读全文
摘要:It is finally here: you can configure the open source log-aggregator, scribe, to log data directly into the Hadoop distributed file system.Many Web 2....
阅读全文
摘要:c++类大小和机器还有编译器有关。64位机器指针大小为8个字节,32位机器为4个字节。每个实例在内存中都有一个独一无二的地址,为了达到这个目的,编译器往往会给一个空类隐含的加一个字节,这样空类在实例化后在内存得到了独一无二的地址;有虚函数的类有个virtual table(虚函数表),里面包含了类的...
阅读全文
摘要:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo...
阅读全文

浙公网安备 33010602011771号