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(); 阅读全文
posted @ 2011-07-30 13:35 Sw_R 阅读(163) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2011-07-29 15:30 Sw_R 阅读(154) 评论(0) 推荐(0) 编辑
摘要:1. Waterfall model:2. Extrem programming: 阅读全文
posted @ 2011-07-16 10:16 Sw_R 阅读(145) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2011-07-14 08:15 Sw_R 阅读(402) 评论(0) 推荐(0) 编辑