change to directory
cd /usr/share/pyshared/nova/scheduler/weights
add a new weight function
vim disk.py
go to bin directory
cd /usr/lib/python2.7/dist-packages/nova/scheduler/weights
change to directory
cd /usr/share/pyshared/nova/scheduler/weights
add a new weight function
vim disk.py
go to bin directory
cd /usr/lib/python2.7/dist-packages/nova/scheduler/weights
打印mxn螺旋矩阵
class Solution {
public:
vector<int> spiralOrder(vector<vector<int> >& matrix) {
vector<int> result;
if (matrix.empty()) return result;
ssize_t beginX = 0, endX = matrix[0].size() - 1;
ssize_t beginY = 0, endY = matrix.size() - 1;
Minimum Window Substring
这是宿舍人面试豌豆荚的一道题,正好没做过,拿来做做
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BANC".
一个链表有一个int数据域,一个next指针域,一个random指针域,random要么指向一个随机的node,要么置空,对此链表进行深拷贝
/**
* Definition for singly-linked list with a random pointer.
* struct RandomListNode {
* int label;
* RandomListNode *next, *random;
* RandomListNode(int x) : label(x), next(NULL), random(NULL) {}
* };
get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.
set(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item.
哈希表存储映射关系可以在O(1)时间内实现快速查找,利用双向链表存储节点信息,O(1)时间内交换节点。头结点保存最近使用的,尾节点保存最近最少使用的,get时更新最近使用节点(即将当前节点更新至头结点)