摘要: unordered_map mp;if (mp.find(key) == mp.end())unordered_map::iterator it = mp.find(deltmp->key);mp.erase(it);mp.clear();map[k]++ // this includes the case when count of k from 0 to 1for (unordered_map::iterator it = mp.begin(); it != mp.end(); it++) { int result = num_stack.top();num_stack.pop(); 阅读全文
posted @ 2014-01-09 19:47 阿牧遥 阅读(294) 评论(0) 推荐(0)
摘要: 逆波兰表达式,情况不是很复杂,用一个栈就解决了。 #include <stack> #include <string> using namespace std; class Solution { public: int evalRPN(vector<string> &tokens) { for (i 阅读全文
posted @ 2014-01-09 15:28 阿牧遥 阅读(272) 评论(0) 推荐(0)
摘要: 双链表+map 实现。所有数据存在链表里,map里存key到Node*的映射。注意当删除时除了要从链表尾部删除节点外,还要map.erase(it)。Node里也要有key,因为为了删除时方便找到it。 #include <map> using namespace std; class Node { 阅读全文
posted @ 2014-01-09 13:37 阿牧遥 阅读(189) 评论(0) 推荐(0)