Time: 2015-08-11 11:30 ~ 12:30
Venue: 11/F, Building B, Ying Mansion, 48th Jia Chun Road, China today's headline
1. I asked a lot about the project of my resume first.
2. Algorithm title: An array in sequence, starting from a position to move the number of subsequent to the front. For example, "123456789" moves from the 7th element to the first, "789123456", in which case a number is found.
intSearchintA[],intLeftintRightinttarget) { if(Left <Right )return-1; intMiddle = (left + right)/2; if(A[middle] = =target)returnMiddle; Else if(A[right] <target)returnSearch (A, left, middle-1, Target); Else if(A[middle] <target)returnSearch (A, Middle +1, right, target); Else returnSearch (A, left, middle-1, target);}
3. Algorithm design questions:
Implement a method bool visit (const string &IP); This method satisfies the requirement, restricts the maximum access to 5w per IP address within one hours, and returns false if it exceeds 5w, otherwise true. Note: This hour is sliding. That is, the range that has been moving over time.
structIpinfo {intcount[3600];//stores the number of accesses per second intIndex//Index of Count intTotal_visits;//number of visits during the hour intLast_time;//time of last visit, in seconds intCnt_visits;//current number of accesses in this second};map<string, ipinfo>Ip_info;BOOLVisitConst string&IP) { Const intCnt_time = Get_cnt_time ();//gets the current time, in seconds if(Ip_info.find (IP) = =Ip_info.end ()) { //the IP address is accessed for the first timeipinfo IPF; Ipf.index=0; Ipf.total_visits=0; Ipf.last_time=Cnt_time; Ipf.cnt_visits=1; IP_INFO[IP]=IPF; return true; } ipinfo&IPF =Ip_info[ip]; intcnt_total_visits, old; if(Ipf.last_time = =cnt_time) { //Last time, it was the same second visit.ipf.cnt_visits++; Cnt_total_visits= Ipf.total_visits-ipf.count[ipf.index] +ipf.cnt_visits; if(Cnt_total_visits >50000) return false; return true; } Else { //follow the last one that was not accessed in the same second.//write Last_time traffic to Count[index]Ipf.total_visits-=Ipf.count[ipf.index]; Ipf.count[ipf.index]=ipf.cnt_visits; Ipf.total_visits+=ipf.cnt_visits; Ipf.index++; Ipf.index%=3600; if(Cnt_time > Ipf.last_time +1) { //last_time = 3s//cnt_time = 5s//then you need to move the index 2 times, and total_visits to subtract those old traffic inti = cnt_time-ipf.last_time-1; while(i--) {ipf.total_visits-=Ipf.count[ipf.index]; Ipf.count[ipf.index]=0; Ipf.index++; Ipf.index%=3600; }} ipf.cnt_visits=1; Ipf.last_time=Cnt_time; if(Ipf.total_visits +1>50000) return false; return true; }}
4. What books have you read?
"C++primer"
"C + + programming language"
"Effective C + +"
5. What projects have you done?
1. Have seen chrome source code. About one months.
2. Projects related to the ALG algorithm. Https://github.com/loverszhaokai/ALG
2015-08-11 [today's headline]--data capture and processing engineer--2 face