ARTS 日常打卡 - 7
发布于: 1 小时前

Algorithm:双端循环队列
class MyCircularDeque {public: /** Initialize your data structure here. Set the size of the deque to be k. */ vector<int> arr; int cnt, head, tail; //当钱队列元素数量 头指针 尾指针 MyCircularDeque(int k): arr(k), head(0), tail(0), cnt(0) {} /** Adds an item at the front of Deque. Return true if the operation is successful. */ bool insertFront(int value) { if (isFull()) return false; head = head - 1; if (head == -1) head = arr.size() - 1; arr[head] = value; cnt += 1; return true; } /** Adds an item at the rear of Deque. Return true if the operation is successful. */ bool insertLast(int value) { if(isFull()) return false; arr[tail] = value; tail +=1; if(tail == arr.size()) tail = 0; cnt += 1; return true; } /** Deletes an item from the front of Deque. Return true if the operation is successful. */ bool deleteFront() { if(isEmpty()) return false;
head = (head+1) % arr.size(); cnt -= 1;
return true; } /** Deletes an item from the rear of Deque. Return true if the operation is successful. */ bool deleteLast() { if(isEmpty()) return false;
tail = (tail -1 + arr.size()) % arr.size(); cnt -= 1;
return true; } /** Get the front item from the deque. */ int getFront() { if(isEmpty()) return -1;
return arr[head]; } /** Get the last item from the deque. */ int getRear() { if(isEmpty()) return -1; return arr[(tail - 1 + arr.size()) % arr.size()]; } /** Checks whether the circular deque is empty or not. */ bool isEmpty() { return cnt == 0; } /** Checks whether the circular deque is full or not. */ bool isFull() { return arr.size() == cnt; }};
/** * Your MyCircularDeque object will be instantiated and called as such: * MyCircularDeque* obj = new MyCircularDeque(k); * bool param_1 = obj->insertFront(value); * bool param_2 = obj->insertLast(value); * bool param_3 = obj->deleteFront(); * bool param_4 = obj->deleteLast(); * int param_5 = obj->getFront(); * int param_6 = obj->getRear(); * bool param_7 = obj->isEmpty(); * bool param_8 = obj->isFull(); */复制代码
Review:移动端 rem 和 vw, 及布局
最近在写移动端表单页面,布局交互都得自己设计,在此重新读了这俩篇文章。
Tip:修改 windows server 用户登录密码
登录 windows server 时忘记了管理员 administration 的密码,可以通过
控制面板 - 管理工具 - 计算机管理
找到 本地用户和组 - 用户
选择需要修改密码的用户 右键 设置密码
Share:VIM 的使用
划线
评论
复制
发布于: 1 小时前阅读数: 7
pjw
关注
还未添加个人签名 2018.04.24 加入
还未添加个人简介











评论