Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu...
分类:
系统相关 时间:
2015-06-14 16:23:48
阅读次数:
176
Implement a trie withinsert,search, andstartsWithmethods.Note:You may assume that all inputs are consist of lowercase lettersa-z.构建字典树class TrieNode {...
分类:
其他好文 时间:
2015-06-14 14:58:14
阅读次数:
125
【题目】
Implement a basic calculator to evaluate a simple expression string.
The expression string may contain open ( and closing parentheses ),
the plus + or minus sign -, non-negative integer...
分类:
其他好文 时间:
2015-06-14 12:31:38
阅读次数:
122
【题目】
Implement the following operations of a stack using queues.
push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() -- R...
分类:
其他好文 时间:
2015-06-14 10:59:41
阅读次数:
160
https://leetcode.com/problems/implement-stack-using-queues/Implement the following operations of a stack using queues.push(x) -- Push element x onto s...
分类:
其他好文 时间:
2015-06-13 16:54:34
阅读次数:
154
Implement the following operations of a stack using queues.
push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() -- Return whet...
分类:
其他好文 时间:
2015-06-13 15:42:34
阅读次数:
132
LeetCode Implement Stack using Queues题目思路就是个模拟;
如果把队头当做栈顶,只是push函数比较麻烦;
如果把队尾当做栈顶,pop和top函数都比较麻烦;
这里采用第一种方法;代码class Stack {
public:
void push(int x) {
Q.push(x);
int size = Q.siz...
分类:
其他好文 时间:
2015-06-13 11:28:37
阅读次数:
151
用queue实现stack题目要求:Implement the following operationspush(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get...
分类:
其他好文 时间:
2015-06-13 07:35:36
阅读次数:
209
Implement Stack using QueuesImplement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the eleme...
分类:
编程语言 时间:
2015-06-13 01:04:13
阅读次数:
249
Preview:1.Implement strStr()O(m*n): 1 class Solution 2 { 3 public: 4 int strStr(string haystack,string needle) 5 { 6 for(int i=0;i<=in...
分类:
其他好文 时间:
2015-06-12 23:42:00
阅读次数:
127