07 2011 档案
摘要:1. use a hashmap.#include<unordered_map>#include<iostream>#include<fstream>using namespace std;int main(){ ifstream file("a.txt"); string line; unordered_map<char, int> hashmap; unordered_map<char, int>::iterator itr; while(file.good()) { char c = file.get();
阅读全文
摘要:This is a typical technical interview question.First, we have to know what is a LRU cache. http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_UsedLeast Recently Used(LRU): discards the least recently used items first. This algorithm requires keeping track of what was used when, which is ex
阅读全文
摘要:1. Waterfall model:2. Extrem programming:
阅读全文
摘要:1.C实现atoi: string转成int,这个函数最基本的要考虑益处和符号。这里不太清楚怎么判断整数溢出了。。int myatoi(const char* str){ int i = 0; int sign = 1; if(*str == '-') { sign = 0; str++; } while(*str) { i = i*10 + *str - '0'; str++; } if(sign == 0) i *= -1; return i;}2.arraylist里面有乱序的数字,如何找出两个数字使得和为0, O(n), 如何找出三个数字和为0, O(n
阅读全文